File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44def main ():
55 cmd = 'git describe --always --long'
6- output = check_output (cmd .split ()).decode ('utf-8' ).strip ().split ('-' )
6+ # describe --long usually outputs "tag-numberofcommits-commitname"
7+ output = check_output (cmd .split ()).decode ('utf-8' ).strip ().rsplit ('-' ,2 )
78 if len (output ) == 3 :
89 version , build , commit = output
910 else :
10- raise Exception ("Could not git describe, (got %s)" % output )
11+ # If the clone is shallow, describe's output won't have tag and
12+ # number of commits. This is a particular issue on Travis-CI,
13+ # which by default clones with a depth of 50.
14+ # This behaviour isn't well documented in git-describe docs,
15+ # but see, e.g., https://stackoverflow.com/a/36389573/1008142
16+ # and https://github.com/travis-ci/travis-ci/issues/3412
17+ version = 'unknown'
18+ build = 'unknown'
19+ # we don't ever expect just one dash from describe --long, but
20+ # just in case:
21+ commit = '-' .join (output )
1122
1223 print ("Version: %s" % version )
1324 print ("Build: %s" % build )
You can’t perform that action at this time.
0 commit comments