diff --git a/dist/index.js b/dist/index.js index 0a33ea1..e83c1b0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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'); diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index 01aedfe..731fbb2 100644 --- a/src/git-command-manager.ts +++ b/src/git-command-manager.ts @@ -41,6 +41,7 @@ export interface IGitCommandManager { submoduleForeach(command: string, recursive: boolean): Promise submoduleSync(recursive: boolean): Promise submoduleUpdate(fetchDepth: number, recursive: boolean): Promise + submoduleStatus(): Promise tagExists(pattern: string): Promise tryClean(): Promise tryConfigUnset(configKey: string, globalConfig?: boolean): Promise @@ -357,6 +358,11 @@ class GitCommandManager { await this.execGit(args) } + async submoduleStatus(): Promise { + const output = await this.execGit(['submodule', 'status'], true) + return output.exitCode === 0 + } + async tagExists(pattern: string): Promise { const output = await this.execGit(['tag', '--list', pattern]) return !!output.stdout.trim() diff --git a/src/git-directory-helper.ts b/src/git-directory-helper.ts index 2979e97..ac61454 100644 --- a/src/git-directory-helper.ts +++ b/src/git-directory-helper.ts @@ -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')