package-manager
package-manager copied to clipboard
Cannot use template which is in Git detached HEAD state
The machinery currently cloning the template repository breaks if the configured template is in a Git detached HEAD state, e.g., in image zeekurity/zeek:5.0.2
:
# Create valid template repo, but in Git detached HEAD state
$ git clone https://github.com/zeek/package-template
$ cd package-template && git checkout origin/master
# Attempt to use the template fails.
$ ZKG_DEFAULT_TEMPLATE=$PWD zkg create --packagedir /tmp/foo
Traceback (most recent call last):
File "/usr/local/zeek/bin/zkg", line 2770, in <module>
main()
File "/usr/local/zeek/bin/zkg", line 2767, in main
args.run_cmd(manager, args, config, configfile)
File "/usr/local/zeek/bin/zkg", line 2085, in cmd_create
tmpl = Template.load(config, tmplname, args.version)
File "/usr/local/zeek/lib/zeek/python/zeekpkg/template.py", line 100, in load
version = repo.head.ref.commit.hexsha[:8]
File "/usr/lib/python3/dist-packages/git/refs/symbolic.py", line 272, 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 '1d5a647f6e9238bad0f0d1c736e899860d04b17d'
This makes it e.g., hard to bisect regressions in a template with Git, or requires workarounds when implementing CI for a package template as Github checkout by default leaves a repo in detached HEAD state.