diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-10-20 11:29:14 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2017-10-20 11:29:14 +0200 |
commit | 02978fb1f6ec4874440df237b4b5f7806cc23681 (patch) | |
tree | 307efc6aea237e80e45c18910d4a1663503c5c75 | |
parent | 15510515a5fa98d212082057effb6b002310125e (diff) |
pq: let drop work when pq branch is checked out
-rw-r--r-- | gbp/scripts/common/pq.py | 8 | ||||
-rw-r--r-- | tests/component/rpm/test_pq_rpm.py | 19 |
2 files changed, 17 insertions, 10 deletions
diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py index be663a3e..70d41be3 100644 --- a/gbp/scripts/common/pq.py +++ b/gbp/scripts/common/pq.py @@ -343,12 +343,8 @@ def apply_and_commit_patch(repo, patch, fallback_author, topic=None, name=None): def drop_pq(repo, branch): - if is_pq_branch(branch): - gbp.log.err("On a patch-queue branch, can't drop it.") - raise GbpError - else: - pq_branch = pq_branch_name(branch) - + repo.checkout(pq_branch_base(branch)) + pq_branch = pq_branch_name(branch) if repo.has_branch(pq_branch): repo.delete_branch(pq_branch) gbp.log.info("Dropped branch '%s'." % pq_branch) diff --git a/tests/component/rpm/test_pq_rpm.py b/tests/component/rpm/test_pq_rpm.py index 15b6d89f..683852d7 100644 --- a/tests/component/rpm/test_pq_rpm.py +++ b/tests/component/rpm/test_pq_rpm.py @@ -165,10 +165,21 @@ class TestPqRpm(RpmRepoTestBase): repo.set_branch('patch-queue/master') branches = repo.get_local_branches() - # Drop pq should fail when on pq branch - eq_(mock_pq(['drop']), 1) - self._check_log(-1, "gbp:error: On a patch-queue branch, can't drop it") - self._check_repo_state(repo, 'patch-queue/master', branches) + # Switch to master + eq_(mock_pq(['switch']), 0) + self._check_repo_state(repo, 'master', branches) + + # Drop should succeed when on master branch + eq_(mock_pq(['drop']), 0) + branches.remove('patch-queue/master') + self._check_repo_state(repo, 'master', branches) + + def test_drop_pq(self): + """drop action should work on pq branch""" + repo = self.init_test_repo('gbp-test') + repo.rename_branch('pq/master', 'patch-queue/master') + repo.set_branch('patch-queue/master') + branches = repo.get_local_branches() # Switch to master eq_(mock_pq(['switch']), 0) |