Merge pull request #112 from crazy-max/fix-git-ref
Some checks failed
publish / publish (push) Has been cancelled
Some checks failed
publish / publish (push) Has been cancelled
git: fall back to git tag in detached HEAD state
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user