summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2009-10-24 21:00:56 +0200
committerGuido Günther <agx@sigxcpu.org>2009-10-24 21:06:11 +0200
commit38fcab2fd4fd674026e222bf14df4146863ac8a8 (patch)
tree0f342d3456e1a2abbbcb283d3c7527423df26447
parent9ccbcd28946b583b9aded117fdbdd7a5af5bc76b (diff)
add --git-retag
Closes: #521329
-rw-r--r--gbp/git.py8
-rwxr-xr-xgit-buildpackage9
2 files changed, 16 insertions, 1 deletions
diff --git a/gbp/git.py b/gbp/git.py
index 5bd7feef..6533b456 100644
--- a/gbp/git.py
+++ b/gbp/git.py
@@ -5,7 +5,7 @@
import subprocess
import os.path
-from command_wrappers import (GitAdd, GitRm, GitCheckoutBranch, GitInit, copy_from)
+from command_wrappers import (GitAdd, GitRm, GitCheckoutBranch, GitInit, GitCommand, copy_from)
import dateutil.parser
import calendar
@@ -65,6 +65,12 @@ class GitRepository(object):
out, ret = self.__git_getoutput('tag', [ '-l', tag ])
return [ False, True ][len(out)]
+ def remove_tag(self, tag):
+ """remove a tag 'tag'"""
+ self.__check_path()
+ if self.has_tag(tag):
+ GitCommand("tag", [ "-d", tag ])()
+
def get_branch(self):
"""on what branch is the current working copy"""
self.__check_path()
diff --git a/git-buildpackage b/git-buildpackage
index 8ccd7c44..7ca276c9 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -193,6 +193,8 @@ def main(argv):
help="create a tag after a successful build")
tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only", default=False,
help="don't build, only tag and run the posttag hook")
+ tag_group.add_option("--git-retag", action="store_true", dest="retag", default=False,
+ help="don't fail if the tag already exists")
tag_group.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags")
tag_group.add_config_file_option(option_name="keyid", dest="keyid")
tag_group.add_config_file_option(option_name="debian-tag", dest="debian_tag")
@@ -224,6 +226,11 @@ def main(argv):
if options.verbose:
Command.verbose = True
+ if options.retag:
+ if not options.tag and not options.tag_only:
+ print >>sys.stderr, "'--%sretag' needs either '--%stag' or '--%stag-only'" % (prefix, prefix, prefix)
+ return 1
+
if options.overlay and not options.export_dir:
parser.error("Overlay must be used with --git-export-dir")
@@ -331,6 +338,8 @@ def main(argv):
if options.tag or options.tag_only:
print "Tagging %s" % version
tag = build_tag(options.debian_tag, version)
+ if options.retag and repo.has_tag(tag):
+ repo.remove_tag(tag)
GitTag(options.sign_tags, options.keyid)(tag,
msg="Debian release %s" % version)
if options.posttag: