Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use template which is in Git detached HEAD state #145

Open
bbannier opened this issue Oct 31, 2022 · 0 comments
Open

Cannot use template which is in Git detached HEAD state #145

bbannier opened this issue Oct 31, 2022 · 0 comments

Comments

@bbannier
Copy link
Member

bbannier commented Oct 31, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant