Skip to content

Commit 8060b9a

Browse files
Jiri Bencstephenfin
authored andcommitted
parser: fix parsing of patches with headings
Some people tend to use lines full of '=' as a fancy way to format headings in their commit messages in a rst-like style. However, the current parser treats such lines as a beginning of a diff. The only currently used tool that produces diffs with '=' lines is quilt in the default configuration. However, even with quilt, the diff looks this way: Index: dir/file =================================================================== --- dir.orig/file +++ dir/file @@ ...etc... It's enough to match on the "Index:" line. The state of the state machine is kept at 1 when it encounters the '=' line, thus it's safe to remove the match on '=' completely. [This prevents us from properly parsing metadata out of the changelog. -dcz ] Signed-off-by: Jiri Benc <jbenc@redhat.com> Reviewed-by: Stephen Finucane <stephen@that.guru> (cherry picked from commit 67faf96)
1 parent 4159ba3 commit 8060b9a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

patchwork/parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,15 +745,15 @@ def parse_patch(content):
745745
# state specified the line we just saw, and what to expect next
746746
state = 0
747747
# 0: text
748-
# 1: suspected patch header (diff, ====, Index:)
748+
# 1: suspected patch header (diff, Index:)
749749
# 2: patch header line 1 (---)
750750
# 3: patch header line 2 (+++)
751751
# 4: patch hunk header line (@@ line)
752752
# 5: patch hunk content
753753
# 6: patch meta header (rename from/rename to)
754754
#
755755
# valid transitions:
756-
# 0 -> 1 (diff, ===, Index:)
756+
# 0 -> 1 (diff, Index:)
757757
# 0 -> 2 (---)
758758
# 1 -> 2 (---)
759759
# 2 -> 3 (+++)
@@ -776,7 +776,7 @@ def parse_patch(content):
776776
line += '\n'
777777

778778
if state == 0:
779-
if line.startswith('diff ') or line.startswith('===') \
779+
if line.startswith('diff ') \
780780
or line.startswith('Index: '):
781781
state = 1
782782
buf += line

0 commit comments

Comments
 (0)