1
0
Fork 0
mirror of https://code.forgejo.org/actions/checkout.git synced 2025-04-28 06:39:55 +02:00

Use rev-list for tags

This commit is contained in:
Luke Tomlinson 2023-05-30 19:07:40 +00:00
parent f095bcc56b
commit 719fedec20
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 {