Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where git_tag_override would fail if "-" in tag name. #18668

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions tensorflow/tools/git/gen_git_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,18 @@ 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.
commits_ahead_of_tag = split_val[-2]
abbrev_commit = split_val[-1]
val = bytes(
"-".join([git_tag_override, commits_ahead_of_tag, abbrev_commit]))
return val if val else unknown_label
except subprocess.CalledProcessError:
return unknown_label
Expand Down