summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2018-01-19 18:27:56 +0100
committerGuido Günther <agx@sigxcpu.org>2018-01-19 18:38:28 +0100
commite1aacbbcb73a12c4eee132f2bbe57a9a6e0e800f (patch)
treefbd4a0c2f2226612b3c9cba558c74a32e089baca
parent5e9ab951b69830d265e7daac1471325a532314a9 (diff)
push: allow to push from detached heads
-rwxr-xr-xgbp/scripts/push.py6
-rw-r--r--tests/component/deb/test_push.py11
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)