Commit 55edef25 authored by Guido Günther's avatar Guido Günther

PatchSeries: Don't fail if there's only a patch end marker

If the patch only has '---' we pass empty data to git-mail-info
otherwise.

Thanks: James Cowgill for the detailed report
Closes: #916545
parent 5426d035
......@@ -83,15 +83,19 @@ class Patch(object):
break
toparse.append(line)
out, err, ret = GitRepository.git_inout(command='mailinfo',
args=['-k', body.name, '/dev/null'],
input=b''.join(toparse),
extra_env=None,
cwd=None,
capture_stderr=True)
if ret != 0:
raise GbpError("Failed to read patch header of '%s': %s" %
(self.path, err))
input = b''.join(toparse)
if input.strip():
out, err, ret = GitRepository.git_inout(command='mailinfo',
args=['-k', body.name, '/dev/null'],
input=input,
extra_env=None,
cwd=None,
capture_stderr=True)
if ret != 0:
raise GbpError("Failed to read patch header of '%s': %s" %
(self.path, err))
else:
out = b''
# Header
for line in out.decode().split('\n'):
......
......@@ -126,3 +126,14 @@ reproducible build
Author: Alexis Bienvenüe <pado@passoire.fr>
""",
p.long_desc)
class TestMarkerOnly(unittest.TestCase):
data_dir = os.path.splitext(__file__)[0] + '_data'
def test_parse(self):
"""Don't fail on empty patch header"""
patchfile = os.path.join(self.data_dir, "916545.patch")
self.assertTrue(os.path.exists(patchfile))
p = Dep3Patch(patchfile)
self.assertEqual("916545", p.subject)
---
--- /dev/null
+++ b/foo
@@ -0,0 +1,1 @@
+foo
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment