1212
1313
1414def guessVersionName ():
15- """Guess a version name
15+ """Guess a version name.
1616
1717 Returns
1818 -------
1919 name : `str`
2020 Descriptive name of the repository version state.
2121 """
22+ name = "unknown"
2223
2324 if not os .path .exists (".git" ):
24- state .log .warn ("Cannot guess version without .git directory; version will be set to 'unknown'." )
25- return "unknown"
26- status = utils .runExternal ("git status --porcelain --untracked-files=no" , fatal = True )
27- if status .strip ():
28- raise RuntimeError ("Error with git version: uncommitted changes" )
29- desc = utils .runExternal ("git describe --tags --always" , fatal = True )
30- return desc .strip ()
25+ state .log .warn (f"Cannot guess version without .git directory; will be set to '{ name } '." )
26+ else :
27+ name = utils .runExternal ("git describe --always --dirty" , fatal = False ).strip ()
28+
29+ return name
3130
3231
3332def guessFingerprint ():
@@ -37,19 +36,14 @@ def guessFingerprint():
3736 -------
3837 fingerprint : `str`
3938 SHA1 of current repository state.
40- modified : `bool`
41- Flag to indicate whether the repository is in a modified state.
4239 """
43- fingerprint , modified = "0x0" , False
40+ fingerprint = "0x0"
4441
4542 if not os .path .exists (".git" ):
4643 state .log .warn (f"Cannot guess fingerprint without .git directory; will be set to '{ fingerprint } '." )
4744 else :
48- status = utils .runExternal ("git status --porcelain --untracked-files=no" , fatal = True )
49- if status .strip ():
50- modified = True
51- output = utils .runExternal ("git rev-parse HEAD" , fatal = False )
52-
53- fingerprint = output .strip ()
45+ fingerprint = utils .runExternal (
46+ "git describe --match=" " --always --abbrev=0 --dirty" , fatal = False
47+ ).strip ()
5448
55- return fingerprint , modified
49+ return fingerprint
0 commit comments