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

versioneer does not fall back to parent-name-prefix method when used with "git archive" on an untagged revision #130

Open
chrivers opened this issue Nov 16, 2016 · 0 comments

Comments

@chrivers
Copy link

I believe I've discovered a bug in versioneer. Here's an example repos:

$ git log --format=oneline --abbrev-commit --decorate
e85b611 (HEAD, master)  + Added gitignore
e19e5a6  + Added .gitattributes
d3f82ec  + Added example files
0098d7a  + Added versioneer

$ git tag -a 0.1 -m 0.1 e19e5a6

$ ./setup.py -V
0.1+1.ge85b611

$ mkdir head  &&  git archive --format=tar HEAD | tar -C head -x

$ mkdir head-parent &&  git archive --format=tar 'HEAD~1' | tar -C head-parent -x

$ cd head && ./setup.py version
running version
discarding 'HEAD,master', no digits
likely tags:
no suitable tags, using unknown + full revision id
got version from expanded keyword {'error': 'no suitable tags', 'date': None, 'version': '0+unknown', 'dirty': False, 'full-revisionid': 'e85b611532c7611077ffd2bf2eeb039d76b2e61a'}
Version: 0+unknown
 full-revisionid: e85b611532c7611077ffd2bf2eeb039d76b2e61a
 dirty: False
 date: None
 error: no suitable tags

$ cd head-parent && ./setup.py version
running version
likely tags: 0.1
picking 0.1
got version from expanded keyword {'error': None, 'date': '2016-11-16T12:50:37+0100', 'version': '0.1', 'dirty': False, 'full-revisionid': 'e19e5a611f5bb1deba1586579ce4684e95297b6a'}
Version: 0.1
 full-revisionid: e19e5a611f5bb1deba1586579ce4684e95297b6a
 dirty: False
 date: 2016-11-16T12:50:37+0100

Getting version 0+unknown isn't particularly helpful at all here. Especially not since I can get a much more reasonable version like this:

$ rm .gitattributes

$mkdir head-no-attrib &&  git archive --format=tar --worktree-attributes 'HEAD' --prefix=problem-0.1/ | tar -C head-no-attrib -x
$ cd head-no-attrib/problem-0.1 && ./setup.py version
running version
keywords are unexpanded, not using
got version from VCS {'error': None, 'date': '2016-11-16T12:52:47+0100', 'version': '0.1+1.ge85b611.dirty', 'dirty': True, 'full-revisionid': 'e85b611532c7611077ffd2bf2eeb039d76b2e61a'}
Version: 0.1+1.ge85b611.dirty
 full-revisionid: e85b611532c7611077ffd2bf2eeb039d76b2e61a
 dirty: True
 date: 2016-11-16T12:52:47+0100

There are very reasonable use cases for this, and I don't see any value in not trying the parent-dir-prefix method if the result is otherwise going to be 0+unknown anyway. Comments?

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