0
1
Fork 0
mirror of https://github.com/actions/checkout synced 2024-07-01 16:32:40 +02:00

Fix Self hosted runner issue wrt bad submodules - solution cleanup working space.

This commit is contained in:
SKi 2023-03-01 19:23:12 -08:00
parent ac59398561
commit 7f14f1d824
No known key found for this signature in database
3 changed files with 21 additions and 0 deletions

10
dist/index.js vendored
View file

@ -7683,6 +7683,12 @@ class GitCommandManager {
yield this.execGit(args);
});
}
submoduleStatus() {
return __awaiter(this, void 0, void 0, function* () {
const output = yield this.execGit(['submodule', 'status'], true);
return output.exitCode === 0;
});
}
tagExists(pattern) {
return __awaiter(this, void 0, void 0, function* () {
const output = yield this.execGit(['tag', '--list', pattern]);
@ -9436,6 +9442,10 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean, ref
}
}
core.endGroup();
// Check for submodules and delete any existing files if submodules are present
if (!(yield git.submoduleStatus())) {
remove = true;
}
// Clean
if (clean) {
core.startGroup('Cleaning the repository');

View file

@ -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,11 @@ class GitCommandManager {
await this.execGit(args)
}
async submoduleStatus(): Promise<boolean> {
const output = await this.execGit(['submodule', 'status'], true)
return output.exitCode === 0
}
async tagExists(pattern: string): Promise<boolean> {
const output = await this.execGit(['tag', '--list', pattern])
return !!output.stdout.trim()

View file

@ -81,6 +81,11 @@ export async function prepareExistingDirectory(
}
core.endGroup()
// Check for submodules and delete any existing files if submodules are present
if (!(await git.submoduleStatus())){
remove = true
}
// Clean
if (clean) {
core.startGroup('Cleaning the repository')