From caf64cb15e794fc7e13974fab19ce932cf6f563c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Guido=20G=C3=BCnther?= Date: Wed, 26 Jan 2022 08:57:12 +0100 Subject: [PATCH] push: Make --debian-tag='' match the documentation An empty Debian tag indicates "don't care" about the packaging branch. Don't fail in that case but rather push out up to the branch tip: Currently we'd fail like $ gbp push --debian-tag='' guido Traceback (most recent call last): File "/usr/bin/gbp", line 149, in sys.exit(supercommand()) File "/usr/bin/gbp", line 145, in supercommand return module.main(args) File "/usr/lib/python3/dist-packages/gbp/scripts/push.py", line 153, in main to_push['refs'].append((ref, get_push_src(repo, ref, dtag))) UnboundLocalError: local variable 'dtag' referenced before assignment this make it simple to push the current development work via gbp push --debian-tag='' --- gbp/scripts/push.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gbp/scripts/push.py b/gbp/scripts/push.py index 8233ace8..d6876e26 100755 --- a/gbp/scripts/push.py +++ b/gbp/scripts/push.py @@ -133,6 +133,8 @@ def main(argv): try: source = DebianSource(repo.path) branch = repo.branch + dtag = None + if not options.ignore_branch: if branch != options.debian_branch: gbp.log.err("You are not on branch '%s' but %s" % @@ -148,9 +150,13 @@ def main(argv): if repo.has_tag(dtag): to_push['tags'].append(dtag) - if source.is_releasable() and branch: + if branch: ref = 'refs/heads/%s' % branch - to_push['refs'].append((ref, get_push_src(repo, ref, dtag))) + if source.is_releasable() and dtag: + to_push['refs'].append((ref, get_push_src(repo, ref, dtag))) + elif not dtag: + # --debian-tag='': Push branch up to tip + to_push['refs'].append((ref, get_push_src(repo, ref, ref))) if not source.is_native(): if options.upstream_tag != '': -- 2.34.1