From aaf1ff9b49afa1dc0fb9f585fd4e44b186561f17 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Wed, 8 Nov 2017 17:07:25 +1100 Subject: [PATCH] ptl-tool: only create tag if new branch It doesn't make sense to create tags for branches that already exist. Signed-off-by: Patrick Donnelly --- src/script/ptl-tool.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/script/ptl-tool.py b/src/script/ptl-tool.py index 73261da07537e..dabaf964d3908 100755 --- a/src/script/ptl-tool.py +++ b/src/script/ptl-tool.py @@ -286,23 +286,20 @@ def build_branch(args): if branch == 'HEAD': log.info("Leaving HEAD detached; no branch anchors your commits") else: - G.head.reference = G.create_head(branch, force=True) - log.info("Checked out new branch {branch}".format(branch=branch)) - - # tag it for future reference. - for i in range(0, 100): - if i == 0: - name = "testing/%s" % branch - else: - name = "testing/%s_%02d" % (branch, i) - try: - git.refs.tag.Tag.create(G, name) - log.info("Created tag %s" % name) - break - except: - pass - if i == 99: - raise RuntimeException("ran out of numbers") + created_branch = False + try: + G.head.reference = G.create_head(branch) + log.info("Checked out new branch {branch}".format(branch=branch)) + created_branch = True + except: + G.head.reference = G.create_head(branch, force=True) + log.info("Checked out branch {branch}".format(branch=branch)) + + if created_branch: + # tag it for future reference. + tag = "testing/%s" % branch + git.refs.tag.Tag.create(G, tag) + log.info("Created tag %s" % tag) def main(): parser = argparse.ArgumentParser(description="Ceph PTL tool") -- 2.39.5