mirror of
https://github.com/vyos/vyos-build.git
synced 2025-10-01 20:28:40 +02:00
T6115: fix failing builds from detached HEAD (e.g. git tags)
This commit is contained in:
parent
330ee19eeb
commit
3494ab3e0a
@ -286,7 +286,11 @@ if __name__ == "__main__":
|
|||||||
if repo.is_dirty():
|
if repo.is_dirty():
|
||||||
build_git += "-dirty"
|
build_git += "-dirty"
|
||||||
|
|
||||||
# Retrieve git 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
|
git_branch = repo.active_branch.name
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
exit(f'Could not retrieve information from git: {e}')
|
exit(f'Could not retrieve information from git: {e}')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user