python-versioneer: Tag prefix broken on Windows with versioneer 0.21

https://github.com/python-versioneer/python-versioneer/pull/262 contains a fix for handling * on windows unfortunately this breaks detecting the correct version for me.

In our repository https://github.com/qcodes/qcodes all tags are prefixed with v and we have tag_prefix = v this used to work fine however with the latest release of versioneer we get versions reported as unknown + x

Looking at the generated git describe command we see

git describe --tags --always --long --dirty --match v*
v0.29.0-288-g9f93a1286
git describe --tags --always --long --dirty --match v\*
9f93a1286
git describe --tags --always --long --dirty --match v\\*
9f93a1286

so it would seem like the escape of * does not always work correctly. removing the escaped prefix for windows restores normal functionality for us

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 15 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@hwjohn I’ll take that into account and also see if the tag prefix works consistently on all platforms if it is provided.

@mathijsvdv , I would be grateful if you provided a fix.

I think a better solution than what is currently implemented in #274 is to just omit the --match option entirely from the git command if there is no tag prefix. This will avoid any issues with trying to predict the correct escape sequence for a given platform.

AFAIK it is not required to escape the search string as it actually breaks functionality as I get no tag despite the fact I am at the exact commit with the tag, see below from a PowerShell prompt:

(venv) PS > git describe --tags --dirty --always --long --match \\*
6408ff9
(venv) PS > git describe --tags --dirty --always --long --match *
2022.01.1-0-g6408ff9
(venv) PS >
commit 6408ff9937d1473be330c44a5392a23e23a35113 (HEAD -> main, tag: 2022.01.1)
Author: ****************************************
Date:   Mon Jan 31 14:41:24 2022 +0100

    Use versioneer for versioning


(venv) PS > git --version
git version 2.33.0.windows.2
(venv) PS > [System.Environment]::OSVersion

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.19044.0 Microsoft Windows NT 10.0.19044.0


(venv) PS > python setup.py version
running version
keywords are unexpanded, not using
got version from VCS {'version': '0+untagged.87.g6408ff9', 'full-revisionid': '6408ff9937d1473be330c44a5392a23e23a35113', 'dirty': False, 'error': None, 'date': '2022-01-31T14:41:24+0100'}
Version: 0+untagged.87.g6408ff9
 full-revisionid: 6408ff9937d1473be330c44a5392a23e23a35113
 dirty: False
 date: 2022-01-31T14:41:24+0100
(venv) PS >

So I am getting 0+untagged.87.g6408ff9 where I would expect 2022.01.1

I would think that is a separate issue. To debug I would suggest that you confirm that the the git describe function returns something meaningful if you run it from the git bash command line. You can see here https://github.com/python-versioneer/python-versioneer/blob/master/src/git/from_vcs.py#L39 which command versioneer executes