mirror of
				https://github.com/actions/checkout.git
				synced 2025-10-31 11:13:59 +08:00 
			
		
		
		
	Fix: Checkout fail in self-hosted runners when faulty submodule are checked-in (#1196)
* Fix Self hosted runner issue wrt bad submodules - solution cleanup working space. * Fix format with npm run format output * Add mock implementation for new function submoduleStatus * Add 2 test cases for submodule status. * Codeql-Action Analyse revert v1 to v2 --------- Co-authored-by: Bassem Dghaidi <568794+Link-@users.noreply.github.com> Co-authored-by: sminnie <minnie@sankhe.com>
This commit is contained in:
		| @@ -41,6 +41,7 @@ export interface IGitCommandManager { | ||||
|   submoduleForeach(command: string, recursive: boolean): Promise<string> | ||||
|   submoduleSync(recursive: boolean): Promise<void> | ||||
|   submoduleUpdate(fetchDepth: number, recursive: boolean): Promise<void> | ||||
|   submoduleStatus(): Promise<boolean> | ||||
|   tagExists(pattern: string): Promise<boolean> | ||||
|   tryClean(): Promise<boolean> | ||||
|   tryConfigUnset(configKey: string, globalConfig?: boolean): Promise<boolean> | ||||
| @@ -357,6 +358,12 @@ class GitCommandManager { | ||||
|     await this.execGit(args) | ||||
|   } | ||||
|  | ||||
|   async submoduleStatus(): Promise<boolean> { | ||||
|     const output = await this.execGit(['submodule', 'status'], true) | ||||
|     core.debug(output.stdout) | ||||
|     return output.exitCode === 0 | ||||
|   } | ||||
|  | ||||
|   async tagExists(pattern: string): Promise<boolean> { | ||||
|     const output = await this.execGit(['tag', '--list', pattern]) | ||||
|     return !!output.stdout.trim() | ||||
|   | ||||
| @@ -81,6 +81,12 @@ export async function prepareExistingDirectory( | ||||
|       } | ||||
|       core.endGroup() | ||||
|  | ||||
|       // Check for submodules and delete any existing files if submodules are present | ||||
|       if (!(await git.submoduleStatus())) { | ||||
|         remove = true | ||||
|         core.info('Bad Submodules found, removing existing files') | ||||
|       } | ||||
|  | ||||
|       // Clean | ||||
|       if (clean) { | ||||
|         core.startGroup('Cleaning the repository') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 SKi
					SKi