We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents a5b683b + fc85cef commit f05a598Copy full SHA for f05a598
1 file changed
src/git.ts
@@ -61,7 +61,13 @@ export class Git {
61
}
62
63
public static async ref(): Promise<string> {
64
- return await Git.exec(['symbolic-ref', 'HEAD']);
+ return await Git.exec(['symbolic-ref', 'HEAD']).catch(() => {
65
+ // if it fails (for example in a detached HEAD state), falls back to
66
+ // using git tag or describe to get the exact matching tag name.
67
+ return Git.tag().then(tag => {
68
+ return `refs/tags/${tag}`;
69
+ });
70
71
72
73
public static async fullCommit(): Promise<string> {
0 commit comments