Compare commits

...

1 Commits

Author SHA1 Message Date
Luke Tomlinson 719fedec20 Use rev-list for tags 2023-05-30 19:07:40 +00:00
3 changed files with 26 additions and 2 deletions

14
dist/index.js vendored
View File

@ -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 {

View File

@ -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
}

View File

@ -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