diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-11-23 18:32:34 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-11-23 19:24:12 +0100 |
commit | 395209152ef4ef4e0b17b239462bc470513b5540 (patch) | |
tree | 4c6f22a438fe5d6976586117a2b60b414f8b16ac | |
parent | d248720ff924801d8e3de6291d3b2e512169a3ca (diff) | |
download | git-buildpackage-395209152ef4ef4e0b17b239462bc470513b5540.tar.gz git-buildpackage-395209152ef4ef4e0b17b239462bc470513b5540.tar.bz2 git-buildpackage-395209152ef4ef4e0b17b239462bc470513b5540.zip |
pq: Allow to pass in custom fucntion to fetch authorship information
so the RPM based tools don't need to rely on a control file but
can e.g. look at the spec file.
-rw-r--r-- | gbp/scripts/common/pq.py | 8 | ||||
-rwxr-xr-x | gbp/scripts/pq.py | 10 | ||||
-rw-r--r-- | tests/13_test_gbp_pq.py | 31 |
3 files changed, 37 insertions, 12 deletions
diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py index cff5bf36..3f939678 100644 --- a/gbp/scripts/common/pq.py +++ b/gbp/scripts/common/pq.py @@ -145,12 +145,12 @@ def switch_to_pq_branch(repo, branch): repo.set_branch(pq_branch) -def apply_single_patch(repo, branch, patch, topic=None): +def apply_single_patch(repo, branch, patch, get_author_info, topic=None): switch_to_pq_branch(repo, branch) - apply_and_commit_patch(repo, patch, topic) + apply_and_commit_patch(repo, patch, get_author_info, topic) -def apply_and_commit_patch(repo, patch, topic=None): +def apply_and_commit_patch(repo, patch, get_author_info, topic=None): """apply a single patch 'patch', add topic 'topic' and commit it""" author = {'name': patch.author, 'email': patch.email, @@ -158,7 +158,7 @@ def apply_and_commit_patch(repo, patch, topic=None): patch_fn = os.path.basename(patch.path) if not (patch.author and patch.email): - name, email = get_maintainer_from_control(repo) + name, email = get_author_info(repo) if name: gbp.log.warn("Patch '%s' has no authorship information, " "using '%s <%s>'" % (patch_fn, name, email)) diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index fbd59a79..bc572388 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -31,7 +31,7 @@ from gbp.patch_series import (PatchSeries, Patch) from gbp.scripts.common.pq import (is_pq_branch, pq_branch_name, pq_branch_base, write_patch, switch_to_pq_branch, apply_single_patch, apply_and_commit_patch, - drop_pq) + drop_pq, get_maintainer_from_control) PATCH_DIR = "debian/patches/" SERIES_FILE = os.path.join(PATCH_DIR,"series") @@ -146,7 +146,9 @@ def import_quilt_patches(repo, branch, series, tries, force): for patch in queue: gbp.log.debug("Applying %s" % patch.path) try: - apply_and_commit_patch(repo, patch, patch.topic) + apply_and_commit_patch(repo, patch, + get_maintainer_from_control, + patch.topic) except (GbpError, GitRepositoryError): repo.set_branch(branch) repo.delete_branch(pq_branch) @@ -250,7 +252,9 @@ def main(argv): rebase_pq(repo, current) elif action == "apply": patch = Patch(patchfile) - apply_single_patch(repo, current, patch, options.topic) + apply_single_patch(repo, current, patch, + get_maintainer_from_control, + options.topic) elif action == "switch": switch_pq(repo, current) except CommandExecFailed: diff --git a/tests/13_test_gbp_pq.py b/tests/13_test_gbp_pq.py index 9fba870f..f6a13ab3 100644 --- a/tests/13_test_gbp_pq.py +++ b/tests/13_test_gbp_pq.py @@ -21,10 +21,12 @@ class TestApplyAndCommit(testutils.DebianGitTestRepo): patch = gbp.patch_series.Patch( os.path.join(os.path.abspath(os.path.curdir), 'tests/data/foo.patch')) - - gbp.scripts.common.pq.apply_and_commit_patch(self.repo, patch) + + gbp.scripts.common.pq.apply_and_commit_patch(self.repo, patch, None) self.assertIn('foo', self.repo.list_files()) + + @unittest.skipIf(not os.path.exists('/usr/bin/dpkg'), 'Dpkg not found') def test_debian_missing_author(self): """ @@ -43,14 +45,33 @@ class TestApplyAndCommit(testutils.DebianGitTestRepo): # Fake a control file self.add_file("debian/control", "Maintainer: Guido Günther <gg@godiug.net>") - - gbp.scripts.common.pq.apply_and_commit_patch(self.repo, patch) + + c = gbp.scripts.common.pq.get_maintainer_from_control + gbp.scripts.common.pq.apply_and_commit_patch(self.repo, + patch, + c) info = self.repo.get_commit_info('HEAD') self.assertEqual(info['author'].email, 'gg@godiug.net') self.assertIn('foo', self.repo.list_files()) +class TestApplySinglePatch(testutils.DebianGitTestRepo): + """Test L{gbp.pq}'s """ + + def setUp(self): + testutils.DebianGitTestRepo.setUp(self) + self.add_file('bar') + + def test_apply_single_patch(self): + """Test applying a single patch""" + patch = gbp.patch_series.Patch( + os.path.join(os.path.abspath(os.path.curdir), + 'tests/data/foo.patch')) + + gbp.scripts.common.pq.apply_single_patch(self.repo, 'master', patch, + None) + self.assertIn('foo', self.repo.list_files()) + - |