diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-12-23 21:06:34 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-12-23 21:20:36 +0100 |
commit | e31f15bf50d956267182512d6c5febb26812ad1a (patch) | |
tree | c5079082abe627485bcb9d5e21a295d773a0e376 | |
parent | 7b297b719f1a0318b07675dab186cb2ab6459bc5 (diff) |
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:
-rwxr-xr-x | gbp/scripts/pq.py | 6 | ||||
-rw-r--r-- | 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): |