Looks like lib2git includes the optional/conditional 'No newline at
end of file' line within the lines collection of the hunk, which could
throw off the new line count. So rather than that, try checking the
new_lines value to make sure that is 1.
One can see how this scenario is causing the test to fail with the
following patches
Fail:
https://lists.sr.ht/~sircmpwn/email-test-drive/patches/9184
Success:
https://lists.sr.ht/~sircmpwn/email-test-drive/patches/9187
---
email_tutorial/app.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/email_tutorial/app.py b/email_tutorial/app.py
index ace94c7..8d42233 100644
--- a/email_tutorial/app.py
+++ b/email_tutorial/app.py
@@ -71,7 +71,7 @@ def get_reply(diff, mail):
# Note: there will only ever be one since we asserted that this is an
# addition:
hunk = patch.hunks[0]
- if len(hunk.lines) != 1:
+ if hunk.new_lines != 1:
return MIMEText(render_template("wrong-content", **{"from": from_[0]}))
content = hunk.lines[0].content
if stage_1.match(content) is not None:
--
2.16.2.windows.1