mirror of
https://github.com/actions/checkout.git
synced 2024-11-25 02:16: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();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 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) {
|
||||
this.gitEnv[name] = value;
|
||||
}
|
||||
|
@ -1982,7 +1994,7 @@ function testRef(git, ref, commit) {
|
|||
// refs/tags/
|
||||
else if (upperRef.startsWith('REFS/TAGS/')) {
|
||||
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
|
||||
else {
|
||||
|
|
|
@ -35,6 +35,7 @@ export interface IGitCommandManager {
|
|||
log1(format?: string): Promise<string>
|
||||
remoteAdd(remoteName: string, remoteUrl: string): Promise<void>
|
||||
removeEnvironmentVariable(name: string): void
|
||||
revList(ref: string, numberOfRefs: number): Promise<string>
|
||||
revParse(ref: string): Promise<string>
|
||||
setEnvironmentVariable(name: string, value: string): void
|
||||
shaExists(sha: string): Promise<boolean>
|
||||
|
@ -314,6 +315,17 @@ class GitCommandManager {
|
|||
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 {
|
||||
this.gitEnv[name] = value
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ export async function testRef(
|
|||
else if (upperRef.startsWith('REFS/TAGS/')) {
|
||||
const tagName = ref.substring('refs/tags/'.length)
|
||||
return (
|
||||
(await git.tagExists(tagName)) && commit === (await git.revParse(ref))
|
||||
(await git.tagExists(tagName)) && commit === (await git.revList(ref, 1))
|
||||
)
|
||||
}
|
||||
// Unexpected
|
||||
|
|
Loading…
Reference in a new issue