mirror of
https://gitea.com/actions/checkout.git
synced 2025-03-13 18:05:12 +08:00
Merge 37332a5498d4939d8481006e4d187a6d31c72411 into add3486cc3b55d4a5e11c8045058cef96538edc7
This commit is contained in:
commit
777fadabba
@ -738,6 +738,8 @@ async function setup(testName: string): Promise<void> {
|
||||
}),
|
||||
submoduleSync: jest.fn(),
|
||||
submoduleUpdate: jest.fn(),
|
||||
submoduleReset: jest.fn(),
|
||||
submoduleClean: jest.fn(),
|
||||
tagExists: jest.fn(),
|
||||
tryClean: jest.fn(),
|
||||
tryConfigUnset: jest.fn(
|
||||
|
@ -423,6 +423,8 @@ async function setup(testName: string): Promise<void> {
|
||||
submoduleForeach: jest.fn(),
|
||||
submoduleSync: jest.fn(),
|
||||
submoduleUpdate: jest.fn(),
|
||||
submoduleReset: jest.fn(),
|
||||
submoduleClean: jest.fn(),
|
||||
tagExists: jest.fn(),
|
||||
tryClean: jest.fn(async () => {
|
||||
return true
|
||||
|
25
dist/index.js
vendored
25
dist/index.js
vendored
@ -7109,6 +7109,26 @@ class GitCommandManager {
|
||||
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) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const output = yield this.execGit(['tag', '--list', pattern]);
|
||||
@ -7420,6 +7440,11 @@ function getSource(settings) {
|
||||
core.startGroup('Setting up auth for fetching submodules');
|
||||
yield authHelper.configureGlobalAuth();
|
||||
core.endGroup();
|
||||
// Clean existing submodules
|
||||
if (settings.clean) {
|
||||
yield git.submoduleReset(settings.nestedSubmodules);
|
||||
yield git.submoduleClean(settings.nestedSubmodules);
|
||||
}
|
||||
// Checkout submodules
|
||||
core.startGroup('Fetching submodules');
|
||||
yield git.submoduleSync(settings.nestedSubmodules);
|
||||
|
@ -41,6 +41,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>
|
||||
@ -326,6 +328,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()
|
||||
|
@ -176,6 +176,13 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
|
||||
await authHelper.configureGlobalAuth()
|
||||
core.endGroup()
|
||||
|
||||
// Clean existing submodules
|
||||
if (settings.clean)
|
||||
{
|
||||
await git.submoduleReset(settings.nestedSubmodules)
|
||||
await git.submoduleClean(settings.nestedSubmodules)
|
||||
}
|
||||
|
||||
// Checkout submodules
|
||||
core.startGroup('Fetching submodules')
|
||||
await git.submoduleSync(settings.nestedSubmodules)
|
||||
|
Loading…
x
Reference in New Issue
Block a user