summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-03-16 09:45:23 +0100
committerGitHub <noreply@github.com>2024-03-16 09:45:23 +0100
commit50bdf2367f5a2ff2cd719ed4ce58189536bac86c (patch)
tree6bc0a0fedadf9a220ba0b0034f389372bab83217 /scripts
parentd4dd9bfcfa39ba90a6cc19e93a22a7f8a0ed71f6 (diff)
parent3494ab3e0a50ed701a4b127e51b919c2ceb61bc3 (diff)
downloadvyos-build-50bdf2367f5a2ff2cd719ed4ce58189536bac86c.tar.gz
vyos-build-50bdf2367f5a2ff2cd719ed4ce58189536bac86c.zip
Merge pull request #526 from sfinke0/fix-tagged-build
T6115: Fix tagged builds from detached Git HEAD
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build-vyos-image8
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/build-vyos-image b/scripts/build-vyos-image
index 7cef0107..fb7eb540 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 = ""