diff options
author | sfinke0 <sfinke@pewpew.network> | 2024-03-10 22:15:41 +0100 |
---|---|---|
committer | sfinke0 <sebastian+github@finke.io> | 2024-03-14 13:33:58 +0100 |
commit | 3494ab3e0a50ed701a4b127e51b919c2ceb61bc3 (patch) | |
tree | 45069c74b7f5772b9cd76d6a59a2e6dad6301225 /scripts | |
parent | 330ee19eeb56b68ea666e3586d18f91164143d9f (diff) | |
download | vyos-build-3494ab3e0a50ed701a4b127e51b919c2ceb61bc3.tar.gz vyos-build-3494ab3e0a50ed701a4b127e51b919c2ceb61bc3.zip |
T6115: fix failing builds from detached HEAD (e.g. git tags)
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-vyos-image | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/build-vyos-image b/scripts/build-vyos-image index 8b91de5..c6d6ca0 100755 --- a/scripts/build-vyos-image +++ b/scripts/build-vyos-image @@ -286,8 +286,12 @@ if __name__ == "__main__": if repo.is_dirty(): build_git += "-dirty" - # Retrieve git branch name - git_branch = repo.active_branch.name + # Retrieve git branch name or current tag + # Building a tagged release might leave us checking out a git tag that is not the tip of a named branch (detached HEAD) + # Check if the current HEAD is associated with a tag and use its name instead of an unavailable branch name. + git_branch = next((tag.name for tag in repo.tags if tag.commit == repo.head.commit), None) + if git_branch is None: + git_branch = repo.active_branch.name except Exception as e: exit(f'Could not retrieve information from git: {e}') build_git = "" |