mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-04-21 17:12:03 +03:00
clean-submodules
This commit is contained in:
parent
fc0a6fcb57
commit
1f1d74371e
7 changed files with 41 additions and 13 deletions
|
@ -89,21 +89,11 @@ export async function prepareExistingDirectory(
|
|||
|
||||
// Clean
|
||||
if (clean) {
|
||||
core.startGroup('Cleaning the repository')
|
||||
if (!(await git.tryClean())) {
|
||||
core.debug(
|
||||
`The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For further investigation, manually run 'git clean -ffdx' on the directory '${repositoryPath}'.`
|
||||
)
|
||||
remove = true
|
||||
} else if (!(await git.tryReset())) {
|
||||
remove = true
|
||||
}
|
||||
core.endGroup()
|
||||
|
||||
if (remove) {
|
||||
if (!(await cleanExistingDirectory(git, repositoryPath))) {
|
||||
core.warning(
|
||||
`Unable to clean or reset the repository. The repository will be recreated instead.`
|
||||
)
|
||||
remove = true
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
@ -123,3 +113,22 @@ export async function prepareExistingDirectory(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function cleanExistingDirectory(git: IGitCommandManager, repositoryPath: string) {
|
||||
core.startGroup('Cleaning the repository')
|
||||
|
||||
if (!(await git.tryClean())) {
|
||||
core.debug(
|
||||
`The clean command failed. This might be caused by: 1) path too long, 2) permission issue, or 3) file in use. For further investigation, manually run 'git clean -ffdx --recurse-submodules' on the directory '${repositoryPath}'.`
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
if (!(await git.tryReset())) {
|
||||
return false
|
||||
}
|
||||
|
||||
core.endGroup()
|
||||
|
||||
return true
|
||||
}
|
|
@ -230,6 +230,11 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
await authHelper.configureGlobalAuth()
|
||||
core.endGroup()
|
||||
|
||||
if (settings.cleanSubmodules) {
|
||||
core.info('Cleaning the repository again before fetching submodules')
|
||||
await gitDirectoryHelper.cleanExistingDirectory(git, settings.repositoryPath)
|
||||
}
|
||||
|
||||
// Checkout submodules
|
||||
core.startGroup('Fetching submodules')
|
||||
await git.submoduleSync(settings.nestedSubmodules)
|
||||
|
|
|
@ -25,10 +25,15 @@ export interface IGitSourceSettings {
|
|||
commit: string
|
||||
|
||||
/**
|
||||
* Indicates whether to clean the repository
|
||||
* Indicates whether to clean the repository before fetching
|
||||
*/
|
||||
clean: boolean
|
||||
|
||||
/**
|
||||
* Indicates whether to clean the repository before fetching submodules
|
||||
*/
|
||||
cleanSubmodules: boolean
|
||||
|
||||
/**
|
||||
* The filter determining which objects to include
|
||||
*/
|
||||
|
|
|
@ -82,6 +82,10 @@ export async function getInputs(): Promise<IGitSourceSettings> {
|
|||
result.clean = (core.getInput('clean') || 'true').toUpperCase() === 'TRUE'
|
||||
core.debug(`clean = ${result.clean}`)
|
||||
|
||||
// Clean
|
||||
result.cleanSubmodules = (core.getInput('clean-submodules') || core.getInput('clean') || 'true').toUpperCase() === 'TRUE'
|
||||
core.debug(`clean-submodules = ${result.clean}`)
|
||||
|
||||
// Filter
|
||||
const filter = core.getInput('filter')
|
||||
if (filter) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue