Merge pull request #112 from crazy-max/fix-git-ref
Some checks failed
publish / publish (push) Has been cancelled

git: fall back to git tag in detached HEAD state
This commit is contained in:
CrazyMax
2023-06-07 15:17:00 +02:00
committed by GitHub

View File

@@ -61,7 +61,13 @@ export class Git {
}
public static async ref(): Promise<string> {
return await Git.exec(['symbolic-ref', 'HEAD']);
return await Git.exec(['symbolic-ref', 'HEAD']).catch(() => {
// if it fails (for example in a detached HEAD state), falls back to
// using git tag or describe to get the exact matching tag name.
return Git.tag().then(tag => {
return `refs/tags/${tag}`;
});
});
}
public static async fullCommit(): Promise<string> {