mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-05-12 05:01:18 +02:00
Fix eslint script and related code
This commit is contained in:
parent
72f2cec99f
commit
ed3e1da142
12 changed files with 40 additions and 38 deletions
|
@ -8,9 +8,9 @@ import * as path from 'path'
|
|||
import * as regexpHelper from './regexp-helper'
|
||||
import * as stateHelper from './state-helper'
|
||||
import * as urlHelper from './url-helper'
|
||||
import {default as uuid} from 'uuid/v4'
|
||||
import {IGitCommandManager} from './git-command-manager'
|
||||
import {IGitSourceSettings} from './git-source-settings'
|
||||
import {default as uuid} from 'uuid/v4'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
const SSH_COMMAND_KEY = 'core.sshCommand'
|
||||
|
@ -215,7 +215,7 @@ class GitAuthHelper {
|
|||
await fs.promises.mkdir(runnerTemp, {recursive: true})
|
||||
await fs.promises.writeFile(
|
||||
this.sshKeyPath,
|
||||
this.settings.sshKey.trim() + '\n',
|
||||
`${this.settings.sshKey.trim()}\n`,
|
||||
{mode: 0o600}
|
||||
)
|
||||
|
||||
|
@ -306,7 +306,7 @@ class GitAuthHelper {
|
|||
const placeholderIndex = content.indexOf(this.tokenPlaceholderConfigValue)
|
||||
if (
|
||||
placeholderIndex < 0 ||
|
||||
placeholderIndex != content.lastIndexOf(this.tokenPlaceholderConfigValue)
|
||||
placeholderIndex !== content.lastIndexOf(this.tokenPlaceholderConfigValue)
|
||||
) {
|
||||
throw new Error(`Unable to replace auth placeholder in ${configPath}`)
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ class GitAuthHelper {
|
|||
|
||||
private async removeGitConfig(
|
||||
configKey: string,
|
||||
submoduleOnly: boolean = false
|
||||
submoduleOnly = false
|
||||
): Promise<void> {
|
||||
if (!submoduleOnly) {
|
||||
if (
|
||||
|
|
|
@ -266,7 +266,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
await authHelper.removeAuth()
|
||||
core.endGroup()
|
||||
}
|
||||
authHelper.removeGlobalConfig()
|
||||
await authHelper.removeGlobalConfig()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import * as io from '@actions/io'
|
|||
import * as path from 'path'
|
||||
import * as retryHelper from './retry-helper'
|
||||
import * as toolCache from '@actions/tool-cache'
|
||||
import {default as uuid} from 'uuid/v4'
|
||||
import {getServerApiUrl} from './url-helper'
|
||||
import {default as uuid} from 'uuid/v4'
|
||||
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
|
@ -54,7 +54,7 @@ export async function downloadRepository(
|
|||
// a top-level folder and the repository content is inside.
|
||||
const archiveFileNames = await fs.promises.readdir(extractPath)
|
||||
assert.ok(
|
||||
archiveFileNames.length == 1,
|
||||
archiveFileNames.length === 1,
|
||||
'Expected exactly one directory inside archive'
|
||||
)
|
||||
const archiveVersion = archiveFileNames[0] // The top-level folder name includes the short SHA
|
||||
|
@ -135,8 +135,8 @@ async function downloadArchive(
|
|||
? octokit.rest.repos.downloadZipballArchive
|
||||
: octokit.rest.repos.downloadTarballArchive
|
||||
const response = await download({
|
||||
owner: owner,
|
||||
repo: repo,
|
||||
owner,
|
||||
repo,
|
||||
ref: commit || ref
|
||||
})
|
||||
return Buffer.from(response.data as ArrayBuffer) // response.data is ArrayBuffer
|
||||
|
|
|
@ -118,10 +118,10 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||
result.submodules = false
|
||||
result.nestedSubmodules = false
|
||||
const submodulesString = (core.getInput('submodules') || '').toUpperCase()
|
||||
if (submodulesString == 'RECURSIVE') {
|
||||
if (submodulesString === 'RECURSIVE') {
|
||||
result.submodules = true
|
||||
result.nestedSubmodules = true
|
||||
} else if (submodulesString == 'TRUE') {
|
||||
} else if (submodulesString === 'TRUE') {
|
||||
result.submodules = true
|
||||
}
|
||||
core.debug(`submodules = ${result.submodules}`)
|
||||
|
|
|
@ -38,9 +38,9 @@ async function cleanup(): Promise<void> {
|
|||
|
||||
// Main
|
||||
if (!stateHelper.IsPost) {
|
||||
run()
|
||||
void run()
|
||||
}
|
||||
// Post
|
||||
else {
|
||||
cleanup()
|
||||
void cleanup()
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {IGitCommandManager} from './git-command-manager'
|
||||
import * as core from '@actions/core'
|
||||
import * as github from '@actions/github'
|
||||
import {getServerApiUrl, isGhes} from './url-helper'
|
||||
import {IGitCommandManager} from './git-command-manager'
|
||||
|
||||
export const tagsRefSpec = '+refs/tags/*:refs/tags/*'
|
||||
|
||||
|
@ -227,7 +227,7 @@ export async function checkCommitInfo(
|
|||
|
||||
// Expected message?
|
||||
const expectedMessage = `Merge ${expectedHeadSha} into ${expectedBaseSha}`
|
||||
if (commitInfo.indexOf(expectedMessage) >= 0) {
|
||||
if (commitInfo.includes(expectedMessage)) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -28,28 +28,28 @@ export const SshKnownHostsPath = core.getState('sshKnownHostsPath')
|
|||
/**
|
||||
* Save the repository path so the POST action can retrieve the value.
|
||||
*/
|
||||
export function setRepositoryPath(repositoryPath: string) {
|
||||
export function setRepositoryPath(repositoryPath: string): void {
|
||||
core.saveState('repositoryPath', repositoryPath)
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the SSH key path so the POST action can retrieve the value.
|
||||
*/
|
||||
export function setSshKeyPath(sshKeyPath: string) {
|
||||
export function setSshKeyPath(sshKeyPath: string): void {
|
||||
core.saveState('sshKeyPath', sshKeyPath)
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the SSH known hosts path so the POST action can retrieve the value.
|
||||
*/
|
||||
export function setSshKnownHostsPath(sshKnownHostsPath: string) {
|
||||
export function setSshKnownHostsPath(sshKnownHostsPath: string): void {
|
||||
core.saveState('sshKnownHostsPath', sshKnownHostsPath)
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the set-safe-directory input so the POST action can retrieve the value.
|
||||
*/
|
||||
export function setSafeDirectory() {
|
||||
export function setSafeDirectory(): void {
|
||||
core.saveState('setSafeDirectory', 'true')
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as assert from 'assert'
|
||||
import {URL} from 'url'
|
||||
import {IGitSourceSettings} from './git-source-settings'
|
||||
import {URL} from 'url'
|
||||
|
||||
export function getFetchUrl(settings: IGitSourceSettings): string {
|
||||
assert.ok(
|
||||
|
@ -20,7 +20,7 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
|
|||
}
|
||||
|
||||
export function getServerUrl(url?: string): URL {
|
||||
let urlValue =
|
||||
const urlValue =
|
||||
url && url.trim().length > 0
|
||||
? url
|
||||
: process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||
|
|
|
@ -20,7 +20,7 @@ export async function getOrganizationId(): Promise<number | undefined> {
|
|||
return
|
||||
}
|
||||
|
||||
return id as number
|
||||
return id
|
||||
} catch (err) {
|
||||
core.debug(
|
||||
`Unable to load organization ID from GITHUB_EVENT_PATH: ${(err as any)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue