diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-03-16 12:22:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-16 12:22:59 +0100 |
commit | cbd25180f5a18a2e8afe16c4e980b31bff9d4cc5 (patch) | |
tree | 96051f09819a9636ce22ddb359e5c5db993022fe | |
parent | 213c9e34bff3ef72ac9fdc83863dd77db8193f0f (diff) | |
parent | 9a4fb2a8071ad65aae712bafa227453d92feae16 (diff) | |
download | vyos-build-cbd25180f5a18a2e8afe16c4e980b31bff9d4cc5.tar.gz vyos-build-cbd25180f5a18a2e8afe16c4e980b31bff9d4cc5.zip |
Merge pull request #535 from vyos/mergify/bp/sagitta/pr-526
T6115: Fix tagged builds from detached Git HEAD (backport #526)
-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 6bfe3faa..94fedf62 100755 --- a/scripts/build-vyos-image +++ b/scripts/build-vyos-image @@ -273,8 +273,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 = "" |