diff options
author | Christian Breunig <christian@breunig.cc> | 2024-02-25 08:41:46 +0100 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-02-25 09:27:59 +0000 |
commit | b6e6b62b689d8da0d3488c0039307308c3e9ae21 (patch) | |
tree | 1c5e4bd64e0ebd672265bf8ea0b70495aa954767 /scripts/pbuilder-setup | |
parent | b5d545836916db82251354e8c12b1969d42bc1f7 (diff) | |
download | vyos-build-b6e6b62b689d8da0d3488c0039307308c3e9ae21.tar.gz vyos-build-b6e6b62b689d8da0d3488c0039307308c3e9ae21.zip |
T6064: add build error if branch information from Git repository is missing
This was discussed in slack, where a user was missing the Git commit ID in his
custom build
Reason is/was:
git clone --single-branch -b 1.4.0-epa1 https://github.com/vyos/vyos-build
Checks out the 1.4.0-epa1 tag as HEAD and does not clone any branch information.
This results in:
>>> import git
>>> repo = git.Repo('.')
>>> repo.head.object.hexsha[:14]
'bcac2eb1f9b49c'
>>> git_branch = repo.active_branch.name
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/git/repo/base.py", line 881, in active_branch
return self.head.reference
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/git/refs/symbolic.py", line 311, in _get_reference
raise TypeError("%s is a detached symbolic reference as it points to %r" % (self, sha))
TypeError: HEAD is a detached symbolic reference as it points to 'bcac2eb1f9b49cc15ebda65838e5465543dbb9c6'
during the build. The exception handler resets the branch and commit name to an empty string: https://github.com/vyos/vyos-build/blob/a3e60a00b400a1bad8609d5ce1abb0bb7abed7bc/scripts/build-vyos-image#L281-L296
This now adds a proper error message during build so it fails early.
(07:46) vyos_bld 08278c5a1172:/vyos/vyos-build # isobuild -test
Building custom VyOS version: 1.5-test-202402250746
I: Checking if packages required for VyOS image build are installed
build/config
Could not retrieve information from git: HEAD is a detached symbolic reference as it points to '39612f541e55bea19868f50f16d7a6c6e0034ed2'
(cherry picked from commit 7c27657c79046dac8ae509a4eacb1a3a152e2d23)
Diffstat (limited to 'scripts/pbuilder-setup')
0 files changed, 0 insertions, 0 deletions