File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
def main ():
5
5
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 )
7
8
if len (output ) == 3 :
8
9
version , build , commit = output
9
10
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 )
11
22
12
23
print ("Version: %s" % version )
13
24
print ("Build: %s" % build )
You can’t perform that action at this time.
0 commit comments