mirror of
https://github.com/docker/actions-toolkit.git
synced 2024-11-23 11:36:10 +08:00
git: fall back to git tag in detached HEAD state
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
fdd740da2d
commit
fc85cef9e1
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user