summaryrefslogtreecommitdiffhomepage
path: root/tests/component/__init__.py
diff options
context:
space:
mode:
authorMaximiliano Curia <maxy@debian.org>2016-09-11 16:23:11 +0200
committerGuido Günther <agx@sigxcpu.org>2017-12-24 19:47:46 +0100
commit17a471d1fc07935dd85c31d3a7c4ae3ea5c39208 (patch)
tree4ef3b83af5078774ffb0c315f9ededaf3e707938 /tests/component/__init__.py
parent4312e54b6ed154f4149ddcfd1b88a40cc1b4caad (diff)
pq: Parse DEP3 headers
Currently the patch headers in DEP3 format are partially supported, as git's mailinfo only reads the From and Subject fields from the first paragraph. But the default in dep3 patches is Description and Author, that are ignored by git. Even worse, when this fields are in the first paragraph (again the default) git mailinfo drops all the contained information. This patch parses the dep3 headers if git's mailinfo couldn't obtain any useful information, any header other than Subject|Description and Author|From is appended to the patch message. The description field is splitted in first line for the short description and the rest is prepended to the patch message. Closes: #785274
Diffstat (limited to 'tests/component/__init__.py')
-rw-r--r--tests/component/__init__.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/component/__init__.py b/tests/component/__init__.py
index 84acf6a6..c670851f 100644
--- a/tests/component/__init__.py
+++ b/tests/component/__init__.py
@@ -86,6 +86,25 @@ class ComponentTestGitRepository(GitRepository):
blobs = [obj[3] for obj in objs if obj[1] == 'blob']
return set(blobs)
+ def get_head_author_subject(self):
+ out, err, ret = self._git_inout('format-patch', ['-1', '--stdout', '--subject-prefix='],
+ capture_stderr=True)
+ if ret:
+ raise GitRepositoryError("Cannot get head author/subject: %s" %
+ err.strip())
+
+ output = out.decode('utf-8')
+ for line in output.split('\n'):
+ line = line.strip()
+ if not line:
+ # end of headers
+ break
+ if line.startswith('From:'):
+ author = line.replace('From:', '').strip()
+ elif line.startswith('Subject:'):
+ subject = line.replace('Subject:', '').strip()
+ return author, subject
+
class ComponentTestBase(unittest.TestCase, GbpLogTester):
"""Base class for testing cmdline tools of git-buildpackage"""