diff options
author | Michael Case <mikecase@google.com> | 2018-06-14 09:54:26 -0700 |
---|---|---|
committer | Michael Case <mikecase@google.com> | 2018-06-14 09:54:26 -0700 |
commit | f2f4bebe2df4d54bfa7c5ef14ff79f51601d9c7e (patch) | |
tree | 6ab262369e7bddf3b39c1c18c92d40d13647fd0b /tensorflow/tools/git/gen_git_source.py | |
parent | 5ae5ab4b963d372f46eef2cee708a586928f331c (diff) |
Fix git_tag_override option in gen_git_source.py.
This fix was committed to the r1.8 branch but never to master.
Adding this fix to master branch.
Diffstat (limited to 'tensorflow/tools/git/gen_git_source.py')
-rwxr-xr-x | tensorflow/tools/git/gen_git_source.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tensorflow/tools/git/gen_git_source.py b/tensorflow/tools/git/gen_git_source.py index 73dee98bae..cc2288a7fa 100755 --- a/tensorflow/tools/git/gen_git_source.py +++ b/tensorflow/tools/git/gen_git_source.py @@ -164,14 +164,17 @@ def get_git_version(git_base_path, git_tag_override): "git", str("--git-dir=%s/.git" % git_base_path), str("--work-tree=" + git_base_path), "describe", "--long", "--tags" ]).strip()) - if git_tag_override: + if git_tag_override and val: split_val = val.split("-") - if len(split_val) != 3: + if len(split_val) < 3: raise Exception( ("Expected git version in format 'TAG-COMMITS AFTER TAG-HASH' " "but got '%s'") % val) - split_val[0] = git_tag_override - val = bytes("-".join(split_val)) + # There might be "-" in the tag name. But we can be sure that the final + # two "-" are those inserted by the git describe command. + abbrev_commit = split_val[-1] + val = bytes( + "-".join([git_tag_override, "0", abbrev_commit])) return val if val else unknown_label except (subprocess.CalledProcessError, OSError): return unknown_label |