diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-02-06 08:21:50 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2017-02-06 08:21:50 +0100 |
commit | d31fb0b47bb0fc6c25f159caa4c3e2068d9ccbd5 (patch) | |
tree | cfc8a36a2d9a4cfacf82e29a4795c382a74cb149 | |
parent | e52819dc98d93c066d742e3a0885bcb00cd9c519 (diff) |
On a patch-queue branch tag the corresponding debian branch instead.
Eases building and tagging of source format 3.0 (quilt) packages since
one can build from a (throw away) patch-queue branch that has the quilt
patches applied (i.e. patch-queue/master) while the tag is created at
the branch point where the patch-queue branch diverged from master.
(usually the tip).
Closes: #583938
-rw-r--r-- | docs/manpages/gbp-buildpackage.sgml | 12 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage.py | 9 | ||||
-rw-r--r-- | tests/component/deb/test_buildpackage.py | 16 |
3 files changed, 33 insertions, 4 deletions
diff --git a/docs/manpages/gbp-buildpackage.sgml b/docs/manpages/gbp-buildpackage.sgml index 89898377..7356a54b 100644 --- a/docs/manpages/gbp-buildpackage.sgml +++ b/docs/manpages/gbp-buildpackage.sgml @@ -122,7 +122,7 @@ </listitem> <listitem> <para> - (Optionally) tag the tree after a successful build. + (Optionally) tag the current commit after a successful build. </para> </listitem> <listitem> @@ -162,8 +162,14 @@ </term> <listitem> <para> - Add a git tag after a successful build. This is a command line only option - that cannot be specified via &gbp.conf;. + Add a git tag after a successful build. It tags the + currently checked out commmit except when you're on a + patch-queue branch. In that case the corresponding debian + branch is tagged. + </para> + <para> + This is a command line only option that cannot be + specified via &gbp.conf;. </para> </listitem> </varlistentry> diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 453b90d3..f0f504b0 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -35,6 +35,7 @@ from gbp.format import format_str from gbp.git.vfs import GitVfs from gbp.deb.upstreamsource import DebianUpstreamSource from gbp.errors import GbpError +from gbp.scripts.common.pq import is_pq_branch, pq_branch_base import gbp.log import gbp.notifications from gbp.scripts.common.buildpackage import (index_name, wc_name, @@ -782,6 +783,11 @@ def main(argv): 'GBP_BUILD_DIR': build_dir}) )() if options.tag or options.tag_only: + if is_pq_branch(branch): + commit = repo.get_merge_base(branch, pq_branch_base(branch)) + else: + commit = head + tag = repo.version_to_tag(options.debian_tag, source.changelog.version) gbp.log.info("Tagging %s as %s" % (source.changelog.version, tag)) if options.retag and repo.has_tag(tag): @@ -792,8 +798,9 @@ def main(argv): repo.create_tag(name=tag, msg=tag_msg, sign=options.sign_tags, - commit=head, + commit=commit, keyid=options.keyid) + if options.posttag: sha = repo.rev_parse("%s^{}" % tag) Hook('Posttag', options.posttag, diff --git a/tests/component/deb/test_buildpackage.py b/tests/component/deb/test_buildpackage.py index 0567f0b0..1f846fde 100644 --- a/tests/component/deb/test_buildpackage.py +++ b/tests/component/deb/test_buildpackage.py @@ -29,6 +29,7 @@ from nose.tools import ok_, eq_, assert_false, assert_true from gbp.scripts.import_dsc import main as import_dsc from gbp.scripts.buildpackage import main as buildpackage +from gbp.scripts.pq import main as pq class TestBuildpackage(ComponentTestBase): @@ -180,3 +181,18 @@ class TestBuildpackage(ComponentTestBase): self._test_buildpackage(repo, ['--git-no-pristine-tar', '--git-compression-level=9']) out = subprocess.check_output(["file", "../hello-debhelper_2.8.orig.tar.gz"]) ok_("max compression" in out) + + @RepoFixtures.quilt30() + def test_tag_pq_branch(self, repo): + ret = pq(['argv0', 'import']) + eq_(repo.rev_parse('master'), repo.rev_parse('debian/2.8-1^{}')) + eq_(ret, 0) + eq_(repo.branch, 'patch-queue/master') + self.add_file(repo, 'foo.txt') + ret = buildpackage(['argv0', + '--git-tag-only', + '--git-retag', + '--git-ignore-branch']) + eq_(ret, 0) + eq_(repo.branch, 'patch-queue/master') + eq_(repo.rev_parse('patch-queue/master^{}^'), repo.rev_parse('debian/2.8-1^{}')) |