Skip to content

Commit

Permalink
substitute tilde ~ with at @ for git tags
Browse files Browse the repository at this point in the history
Closes: #377
  • Loading branch information
Blaimi committed Sep 11, 2020
1 parent 5575554 commit ee88eaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/tito/builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ def _get_tag_for_version(self, version_and_release):
'version': version,
'release': release
}
# Strip extra dashes if one of the params is empty
return tag_format.format(**kwargs).strip('-')
# Strip extra dashes if one of the params is empty and replace ~ by @
return tag_format.format(**kwargs).strip('-').replace("~", "@")

def copy_extra_sources(self):
"""
Expand Down
14 changes: 7 additions & 7 deletions src/tito/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def render_cheetah(template_file, destination_directory, cheetah_input):


def tag_exists_locally(tag):
(status, output) = getstatusoutput("git tag | grep %s" % tag)
(status, output) = getstatusoutput("git tag | grep %s" % tag.replace("~", "@"))
if status > 0:
return False
else:
Expand All @@ -423,7 +423,7 @@ def tag_exists_remotely(tag):
def get_local_tag_sha1(tag):
tag_sha1 = run_command(
"git ls-remote ./. --tag %s | awk '{ print $1 ; exit }'"
% tag)
% tag.replace("~", "@"))
tag_sha1 = extract_sha1(tag_sha1)
return tag_sha1

Expand All @@ -438,7 +438,7 @@ def head_points_to_tag(tag):
"""
debug("Checking that HEAD commit is %s" % tag)
head_sha1 = run_command("git rev-list --max-count=1 HEAD")
tag_sha1 = run_command("git rev-list --max-count=1 %s" % tag)
tag_sha1 = run_command("git rev-list --max-count=1 %s" % tag.replace("~", "@"))
debug(" head_sha1 = %s" % head_sha1)
debug(" tag_sha1 = %s" % tag_sha1)
return head_sha1 == tag_sha1
Expand All @@ -455,7 +455,7 @@ def undo_tag(tag):

# Using --merge here as it appears to undo the changes in the commit,
# but preserve any modified files:
output = run_command("git tag -d %s && git reset --merge HEAD^1" % tag)
output = run_command("git tag -d %s && git reset --merge HEAD^1" % tag.replace("~", "@"))
print(output)


Expand Down Expand Up @@ -483,7 +483,7 @@ def get_remote_tag_sha1(tag):
repo_url = get_git_repo_url()
print("Checking for tag [%s] in git repo [%s]" % (tag, repo_url))
cmd = "git ls-remote %s --tag %s | awk '{ print $1 ; exit }'" % \
(repo_url, tag)
(repo_url, tag.replace("~", "@"))
upstream_tag_sha1 = run_command(cmd)
upstream_tag_sha1 = extract_sha1(upstream_tag_sha1)
return upstream_tag_sha1
Expand Down Expand Up @@ -788,7 +788,7 @@ def get_build_commit(tag, test=False):
else:
tag_sha1 = run_command(
"git ls-remote ./. --tag %s | awk '{ print $1 ; exit }'"
% tag)
% tag.replace("~", "@"))
tag_sha1 = extract_sha1(tag_sha1)
commit_id = run_command('git rev-list --max-count=1 %s' % tag_sha1)
return commit_id
Expand All @@ -800,7 +800,7 @@ def get_commit_count(tag, commit_id):
# just the tag.
#
# so we need to pass in the tag as well.
# output = run_command("git describe --match=%s %s" % (tag, commit_id))
# output = run_command("git describe --match=%s %s" % (tag.replace("~", "@"), commit_id))
# if tag == output:
# return 0
# else:
Expand Down

0 comments on commit ee88eaf

Please sign in to comment.