mirror of
https://forgejo.mixinet.net/actions/checkout.git
synced 2025-06-15 14:50:45 -06:00
Add reset and clean for submodules
This commit is contained in:
parent
fd47087372
commit
ac7af06d80
3 changed files with 46 additions and 0 deletions
|
@ -40,6 +40,8 @@ export interface IGitCommandManager {
|
|||
submoduleForeach(command: string, recursive: boolean): Promise<string>
|
||||
submoduleSync(recursive: boolean): Promise<void>
|
||||
submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void>
|
||||
submoduleReset(recursive: boolean): Promise<void>
|
||||
submoduleClean(recursive: boolean): Promise<void>
|
||||
tagExists(pattern: string): Promise<boolean>
|
||||
tryClean(): Promise<boolean>
|
||||
tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
|
||||
|
@ -324,6 +326,26 @@ class GitCommandManager {
|
|||
await this.execGit(args)
|
||||
}
|
||||
|
||||
async submoduleReset(recursive: boolean): Promise<void> {
|
||||
const args = ['submodule', 'foreach']
|
||||
if (recursive) {
|
||||
args.push('--recursive')
|
||||
}
|
||||
args.push('git reset --hard')
|
||||
|
||||
await this.execGit(args)
|
||||
}
|
||||
|
||||
async submoduleClean(recursive: boolean): Promise<void> {
|
||||
const args = ['submodule', 'foreach']
|
||||
if (recursive) {
|
||||
args.push('--recursive')
|
||||
}
|
||||
args.push('git clean -ffdx')
|
||||
|
||||
await this.execGit(args)
|
||||
}
|
||||
|
||||
async tagExists(pattern: string): Promise<boolean> {
|
||||
const output = await this.execGit(['tag', '--list', pattern])
|
||||
return !!output.stdout.trim()
|
||||
|
|
|
@ -183,6 +183,8 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
|||
settings.fetchDepth,
|
||||
settings.nestedSubmodules
|
||||
)
|
||||
await git.submoduleReset(settings.nestedSubmodules)
|
||||
await git.submoduleClean(settings.nestedSubmodules)
|
||||
await git.submoduleForeach(
|
||||
'git config --local gc.auto 0',
|
||||
settings.nestedSubmodules
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue