mirror of
https://github.com/actions/checkout.git
synced 2025-08-15 10:35:09 +00:00
linting
This commit is contained in:
parent
6503dcd44c
commit
630cdb3874
@ -22,7 +22,9 @@ export async function prepareExistingDirectory(
|
|||||||
|
|
||||||
// If preserveLocalChanges is true, log it
|
// If preserveLocalChanges is true, log it
|
||||||
if (preserveLocalChanges) {
|
if (preserveLocalChanges) {
|
||||||
core.info(`Preserve local changes is enabled, will attempt to keep local files`)
|
core.info(
|
||||||
|
`Preserve local changes is enabled, will attempt to keep local files`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether using git or REST API
|
// Check whether using git or REST API
|
||||||
@ -132,11 +134,17 @@ export async function prepareExistingDirectory(
|
|||||||
await io.rmRF(path.join(repositoryPath, file))
|
await io.rmRF(path.join(repositoryPath, file))
|
||||||
}
|
}
|
||||||
} else if (remove && preserveLocalChanges) {
|
} else if (remove && preserveLocalChanges) {
|
||||||
core.info(`Skipping deletion of directory contents due to preserve-local-changes setting`)
|
core.info(
|
||||||
|
`Skipping deletion of directory contents due to preserve-local-changes setting`
|
||||||
|
)
|
||||||
// We still need to make sure we have a git repository to work with
|
// We still need to make sure we have a git repository to work with
|
||||||
if (!git) {
|
if (!git) {
|
||||||
core.info(`Initializing git repository to prepare for checkout with preserved changes`)
|
core.info(
|
||||||
await fs.promises.mkdir(path.join(repositoryPath, '.git'), { recursive: true })
|
`Initializing git repository to prepare for checkout with preserved changes`
|
||||||
|
)
|
||||||
|
await fs.promises.mkdir(path.join(repositoryPath, '.git'), {
|
||||||
|
recursive: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||||||
|
|
||||||
for (const [filePath, content] of localFiles.entries()) {
|
for (const [filePath, content] of localFiles.entries()) {
|
||||||
// Check if file exists in git using a child process instead of git.execGit
|
// Check if file exists in git using a child process instead of git.execGit
|
||||||
const { exec } = require('@actions/exec')
|
const {exec} = require('@actions/exec')
|
||||||
let exitCode = 0
|
let exitCode = 0
|
||||||
const output = {
|
const output = {
|
||||||
stdout: '',
|
stdout: '',
|
||||||
@ -313,13 +313,17 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exitCode = await exec('git', ['ls-files', '--error-unmatch', filePath], options)
|
exitCode = await exec(
|
||||||
|
'git',
|
||||||
|
['ls-files', '--error-unmatch', filePath],
|
||||||
|
options
|
||||||
|
)
|
||||||
|
|
||||||
if (exitCode !== 0) {
|
if (exitCode !== 0) {
|
||||||
// File is not tracked by git, safe to restore
|
// File is not tracked by git, safe to restore
|
||||||
const fullPath = path.join(process.cwd(), filePath)
|
const fullPath = path.join(process.cwd(), filePath)
|
||||||
// Ensure directory exists
|
// Ensure directory exists
|
||||||
fs.mkdirSync(path.dirname(fullPath), { recursive: true })
|
fs.mkdirSync(path.dirname(fullPath), {recursive: true})
|
||||||
fs.writeFileSync(fullPath, content)
|
fs.writeFileSync(fullPath, content)
|
||||||
core.info(`Restored local file: ${filePath}`)
|
core.info(`Restored local file: ${filePath}`)
|
||||||
restoredCount++
|
restoredCount++
|
||||||
|
@ -83,7 +83,9 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||||||
core.debug(`clean = ${result.clean}`)
|
core.debug(`clean = ${result.clean}`)
|
||||||
|
|
||||||
// Preserve local changes
|
// Preserve local changes
|
||||||
result.preserveLocalChanges = (core.getInput('preserve-local-changes') || 'false').toUpperCase() === 'TRUE'
|
result.preserveLocalChanges =
|
||||||
|
(core.getInput('preserve-local-changes') || 'false').toUpperCase() ===
|
||||||
|
'TRUE'
|
||||||
core.debug(`preserveLocalChanges = ${result.preserveLocalChanges}`)
|
core.debug(`preserveLocalChanges = ${result.preserveLocalChanges}`)
|
||||||
|
|
||||||
// Filter
|
// Filter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user