From e1aacbbcb73a12c4eee132f2bbe57a9a6e0e800f Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 19 Jan 2018 18:27:56 +0100 Subject: push: allow to push from detached heads --- gbp/scripts/push.py | 6 ++++-- tests/component/deb/test_push.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gbp/scripts/push.py b/gbp/scripts/push.py index 868b0954..e21a022f 100755 --- a/gbp/scripts/push.py +++ b/gbp/scripts/push.py @@ -132,10 +132,12 @@ def main(argv): try: source = DebianSource(repo.path) - branch = repo.get_branch() + branch = repo.branch if not options.ignore_branch: if branch != options.debian_branch: - gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)) + gbp.log.err("You are not on branch '%s' but %s" % + (options.debian_branch, + "on '%s'" % branch if branch else 'in detached HEAD state')) raise GbpError("Use --ignore-branch to ignore or --debian-branch to set the branch name.") if not dest: diff --git a/tests/component/deb/test_push.py b/tests/component/deb/test_push.py index 7d9e485a..35ea5bf0 100644 --- a/tests/component/deb/test_push.py +++ b/tests/component/deb/test_push.py @@ -61,6 +61,17 @@ class TestPush(ComponentTestBase): tags=['debian/2.8-1', 'upstream/2.8']) self.assertEquals(repo.head, self.target.head) + @RepoFixtures.quilt30(opts=['--pristine-tar']) + def test_push_detached_head(self, repo): + repo.checkout("HEAD^{commit}") + repo.add_remote_repo('origin', self.target.path) + self.assertEquals(push(['argv0', '--ignore-branch']), 0) + # Since branch head is detached we don't push it but upstream + # branch and tags must be there: + self._check_repo_state(self.target, None, + ['upstream'], + tags=['debian/2.8-1', 'upstream/2.8']) + @RepoFixtures.native() def test_push_tag_ne_branch(self, repo): repo.add_remote_repo('origin', self.target.path) -- cgit v1.2.3