mirror of
https://code.forgejo.org/actions/checkout.git
synced 2024-11-05 10:12:53 +01:00
Use rev-list for tags
This commit is contained in:
parent
f095bcc56b
commit
719fedec20
3 changed files with 26 additions and 2 deletions
14
dist/index.js
vendored
14
dist/index.js
vendored
|
@ -722,6 +722,18 @@ class GitCommandManager {
|
||||||
return output.stdout.trim();
|
return output.stdout.trim();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Lists SHAs pointed to by a revision.
|
||||||
|
* @param {string} ref For example: 'refs/heads/main' or '/refs/tags/v1'
|
||||||
|
* @param {number} numberOfRefs
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
revList(ref, numberOfRefs) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const output = yield this.execGit(['rev-list', ref, `-${numberOfRefs}`]);
|
||||||
|
return output.stdout.trim();
|
||||||
|
});
|
||||||
|
}
|
||||||
setEnvironmentVariable(name, value) {
|
setEnvironmentVariable(name, value) {
|
||||||
this.gitEnv[name] = value;
|
this.gitEnv[name] = value;
|
||||||
}
|
}
|
||||||
|
@ -1982,7 +1994,7 @@ function testRef(git, ref, commit) {
|
||||||
// refs/tags/
|
// refs/tags/
|
||||||
else if (upperRef.startsWith('REFS/TAGS/')) {
|
else if (upperRef.startsWith('REFS/TAGS/')) {
|
||||||
const tagName = ref.substring('refs/tags/'.length);
|
const tagName = ref.substring('refs/tags/'.length);
|
||||||
return ((yield git.tagExists(tagName)) && commit === (yield git.revParse(ref)));
|
return ((yield git.tagExists(tagName)) && commit === (yield git.revList(ref, 1)));
|
||||||
}
|
}
|
||||||
// Unexpected
|
// Unexpected
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -35,6 +35,7 @@ export interface IGitCommandManager {
|
||||||
log1(format?: string): Promise<string>
|
log1(format?: string): Promise<string>
|
||||||
remoteAdd(remoteName: string, remoteUrl: string): Promise<void>
|
remoteAdd(remoteName: string, remoteUrl: string): Promise<void>
|
||||||
removeEnvironmentVariable(name: string): void
|
removeEnvironmentVariable(name: string): void
|
||||||
|
revList(ref: string, numberOfRefs: number): Promise<string>
|
||||||
revParse(ref: string): Promise<string>
|
revParse(ref: string): Promise<string>
|
||||||
setEnvironmentVariable(name: string, value: string): void
|
setEnvironmentVariable(name: string, value: string): void
|
||||||
shaExists(sha: string): Promise<boolean>
|
shaExists(sha: string): Promise<boolean>
|
||||||
|
@ -314,6 +315,17 @@ class GitCommandManager {
|
||||||
return output.stdout.trim()
|
return output.stdout.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists SHAs pointed to by a revision.
|
||||||
|
* @param {string} ref For example: 'refs/heads/main' or '/refs/tags/v1'
|
||||||
|
* @param {number} numberOfRefs
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
async revList(ref: string, numberOfRefs: number): Promise<string> {
|
||||||
|
const output = await this.execGit(['rev-list', ref, `-${numberOfRefs}`])
|
||||||
|
return output.stdout.trim()
|
||||||
|
}
|
||||||
|
|
||||||
setEnvironmentVariable(name: string, value: string): void {
|
setEnvironmentVariable(name: string, value: string): void {
|
||||||
this.gitEnv[name] = value
|
this.gitEnv[name] = value
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ export async function testRef(
|
||||||
else if (upperRef.startsWith('REFS/TAGS/')) {
|
else if (upperRef.startsWith('REFS/TAGS/')) {
|
||||||
const tagName = ref.substring('refs/tags/'.length)
|
const tagName = ref.substring('refs/tags/'.length)
|
||||||
return (
|
return (
|
||||||
(await git.tagExists(tagName)) && commit === (await git.revParse(ref))
|
(await git.tagExists(tagName)) && commit === (await git.revList(ref, 1))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Unexpected
|
// Unexpected
|
||||||
|
|
Loading…
Reference in a new issue