From e31f15bf50d956267182512d6c5febb26812ad1a Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 23 Dec 2016 21:06:34 +0100 Subject: pq: Don't fail --commit on empty commits So far we would fail empty commits with the confusing error $ gbp pq export --commit gbp:info: Generating patches from git (debian/sid..patch-queue/debian/sid) gbp:error: Error running git commit: --- gbp/scripts/pq.py | 6 ++++-- tests/13_test_gbp_pq.py | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 945cf1ed..37968edd 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -168,8 +168,10 @@ def commit_patches(repo, branch, patches, options, patch_dir): # FIXME: handle case were only the contents of the patches changed added, removed = compare_series(oldpatches, newpatches) msg = format_series_diff(added, removed, options) - repo.add_files(PATCH_DIR) - repo.commit_staged(msg=msg) + + if not repo.is_clean(paths='debian/patches')[0]: + repo.add_files(PATCH_DIR) + repo.commit_staged(msg=msg) return added, removed diff --git a/tests/13_test_gbp_pq.py b/tests/13_test_gbp_pq.py index be87f909..c63ee12d 100644 --- a/tests/13_test_gbp_pq.py +++ b/tests/13_test_gbp_pq.py @@ -210,8 +210,12 @@ class TestWritePatch(testutils.DebianGitTestRepo): class TestExport(testutils.DebianGitTestRepo): class Options(object): - drop = True + drop = False patch_numbers = False + renumber = False + patch_num_format = '' + meta_closes = False + meta_closes_bugnum = '' pq_from = 'DEBIAN' def setUp(self): @@ -223,12 +227,36 @@ class TestExport(testutils.DebianGitTestRepo): repo = self.repo start = repo.get_branch() pq_branch = os.path.join('patch-queue', start) + opts = TestExport.Options() + opts.drop = True + pq.switch_pq(repo, start) self.assertEqual(repo.get_branch(), pq_branch) - export_patches(repo, pq_branch, TestExport.Options) + export_patches(repo, pq_branch, opts) self.assertEqual(repo.get_branch(), start) self.assertFalse(repo.has_branch(pq_branch)) + def test_commit(self): + """Test if we commit the patch-queue branch with --commit""" + repo = self.repo + start = repo.get_branch() + pq_branch = os.path.join('patch-queue', start) + opts = TestExport.Options() + opts.commit = True + pq.switch_pq(repo, start) + self.assertEqual(len(repo.get_commits()), 1) + self.assertEqual(repo.get_branch(), pq_branch) + self.add_file('foo', 'foo') + export_patches(repo, pq_branch, opts) + self.assertEqual(repo.get_branch(), start) + self.assertTrue(repo.has_branch(pq_branch)) + self.assertEqual(len(repo.get_commits()), 2, + "Export did not create commit") + export_patches(repo, pq_branch, opts) + self.assertEqual(repo.get_branch(), start) + self.assertEqual(len(repo.get_commits()), 2, + "Export must not create another commit") + class TestParseGbpCommand(unittest.TestCase): def test_empty_body(self): -- cgit v1.2.3