mirror of
				https://github.com/actions/checkout.git
				synced 2025-11-04 01:13:36 +00:00 
			
		
		
		
	Add reset and clean for submodules
This commit is contained in:
		
							parent
							
								
									fd47087372
								
							
						
					
					
						commit
						ac7af06d80
					
				
							
								
								
									
										22
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							@ -7101,6 +7101,26 @@ class GitCommandManager {
 | 
				
			|||||||
            yield this.execGit(args);
 | 
					            yield this.execGit(args);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    submoduleReset(recursive) {
 | 
				
			||||||
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
 | 
					            const args = ['submodule', 'foreach'];
 | 
				
			||||||
 | 
					            if (recursive) {
 | 
				
			||||||
 | 
					                args.push('--recursive');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            args.push('git reset --hard');
 | 
				
			||||||
 | 
					            yield this.execGit(args);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    submoduleClean(recursive) {
 | 
				
			||||||
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
 | 
					            const args = ['submodule', 'foreach'];
 | 
				
			||||||
 | 
					            if (recursive) {
 | 
				
			||||||
 | 
					                args.push('--recursive');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            args.push('git clean -ffdx');
 | 
				
			||||||
 | 
					            yield this.execGit(args);
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    tagExists(pattern) {
 | 
					    tagExists(pattern) {
 | 
				
			||||||
        return __awaiter(this, void 0, void 0, function* () {
 | 
					        return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
            const output = yield this.execGit(['tag', '--list', pattern]);
 | 
					            const output = yield this.execGit(['tag', '--list', pattern]);
 | 
				
			||||||
@ -7416,6 +7436,8 @@ function getSource(settings) {
 | 
				
			|||||||
                    core.startGroup('Fetching submodules');
 | 
					                    core.startGroup('Fetching submodules');
 | 
				
			||||||
                    yield git.submoduleSync(settings.nestedSubmodules);
 | 
					                    yield git.submoduleSync(settings.nestedSubmodules);
 | 
				
			||||||
                    yield git.submoduleUpdate(settings.fetchDepth, settings.nestedSubmodules);
 | 
					                    yield git.submoduleUpdate(settings.fetchDepth, settings.nestedSubmodules);
 | 
				
			||||||
 | 
					                    yield git.submoduleReset(settings.nestedSubmodules);
 | 
				
			||||||
 | 
					                    yield git.submoduleClean(settings.nestedSubmodules);
 | 
				
			||||||
                    yield git.submoduleForeach('git config --local gc.auto 0', settings.nestedSubmodules);
 | 
					                    yield git.submoduleForeach('git config --local gc.auto 0', settings.nestedSubmodules);
 | 
				
			||||||
                    core.endGroup();
 | 
					                    core.endGroup();
 | 
				
			||||||
                    // Persist credentials
 | 
					                    // Persist credentials
 | 
				
			||||||
 | 
				
			|||||||
@ -40,6 +40,8 @@ export interface IGitCommandManager {
 | 
				
			|||||||
  submoduleForeach(command: string, recursive: boolean): Promise<string>
 | 
					  submoduleForeach(command: string, recursive: boolean): Promise<string>
 | 
				
			||||||
  submoduleSync(recursive: boolean): Promise<void>
 | 
					  submoduleSync(recursive: boolean): Promise<void>
 | 
				
			||||||
  submoduleUpdate(fetchDepth: number, 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>
 | 
					  tagExists(pattern: string): Promise<boolean>
 | 
				
			||||||
  tryClean(): Promise<boolean>
 | 
					  tryClean(): Promise<boolean>
 | 
				
			||||||
  tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
 | 
					  tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean>
 | 
				
			||||||
@ -324,6 +326,26 @@ class GitCommandManager {
 | 
				
			|||||||
    await this.execGit(args)
 | 
					    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> {
 | 
					  async tagExists(pattern: string): Promise<boolean> {
 | 
				
			||||||
    const output = await this.execGit(['tag', '--list', pattern])
 | 
					    const output = await this.execGit(['tag', '--list', pattern])
 | 
				
			||||||
    return !!output.stdout.trim()
 | 
					    return !!output.stdout.trim()
 | 
				
			||||||
 | 
				
			|||||||
@ -183,6 +183,8 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
 | 
				
			|||||||
          settings.fetchDepth,
 | 
					          settings.fetchDepth,
 | 
				
			||||||
          settings.nestedSubmodules
 | 
					          settings.nestedSubmodules
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					        await git.submoduleReset(settings.nestedSubmodules)
 | 
				
			||||||
 | 
					        await git.submoduleClean(settings.nestedSubmodules)
 | 
				
			||||||
        await git.submoduleForeach(
 | 
					        await git.submoduleForeach(
 | 
				
			||||||
          'git config --local gc.auto 0',
 | 
					          'git config --local gc.auto 0',
 | 
				
			||||||
          settings.nestedSubmodules
 | 
					          settings.nestedSubmodules
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user