From f900eb68b640ec0faa08eb0a15ccc381e241d231 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 15 Jan 2025 08:51:28 +0100 Subject: [PATCH] [FIX] runbot_merge: my pager lied to me Hopefully this is the last fix to the patcher. From the start of the implementation I relied on the idea that `git show` was adding a line composed of a single space (and a newline) before and after the patch message, as that is what I observed in my terminal, and it's consistent with RFC 3676 signatures (two dashes, a space, and a newline). Turns out that single space, while present in my terminal indeed, was completely made up by `less(1)`. `git show` itself doesn't generate that, neither does it appear when using most pagers, or even when piping the output of `less` into something (a file, an other pager, ...). It's pretty much just something `less(1)` sends to a terminal during interactive sessions to fuck with you. Fixes #1037 --- runbot_merge/models/patcher.py | 4 ++-- runbot_merge/tests/test_patching.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runbot_merge/models/patcher.py b/runbot_merge/models/patcher.py index 80fc20d3..83e47d93 100644 --- a/runbot_merge/models/patcher.py +++ b/runbot_merge/models/patcher.py @@ -75,11 +75,11 @@ def parse_show(p: Patch) -> ParseResult: f"found {header}.\nOnly 'medium' and 'fuller' formats are supported") # skip possible extra headers before the message - while next(lines, ' \n') != ' \n': + while not next(lines, ' ').isspace(): continue body = [] - while (l := next(lines, ' \n')) != ' \n': + while (l := next(lines, '')) and l.startswith(' '): body.append(l.removeprefix(' ')) # remainder should be the patch diff --git a/runbot_merge/tests/test_patching.py b/runbot_merge/tests/test_patching.py index a273e9cf..46dc516f 100644 --- a/runbot_merge/tests/test_patching.py +++ b/runbot_merge/tests/test_patching.py @@ -9,11 +9,11 @@ BASIC_UDIFF = """\ commit 0000000000000000000000000000000000000000 Author: 3 Discos Down Date: 2021-04-24T17:09:14Z - + whop whop whop - + diff --git a/b b/b index 000000000000..000000000000 100644 --- a/b