From patchwork Thu Jun 28 19:42:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Zickus X-Patchwork-Id: 936379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GqtW6GxFz9ryk for ; Fri, 29 Jun 2018 05:42:27 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41GqtW51rKzF1XM for ; Fri, 29 Jun 2018 05:42:27 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=dzickus@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41GqtP6vwtzF1S9 for ; Fri, 29 Jun 2018 05:42:18 +1000 (AEST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BC14401DEB0; Thu, 28 Jun 2018 19:42:16 +0000 (UTC) Received: from dzickus-laptop.redhat.com (ovpn-124-64.rdu2.redhat.com [10.10.124.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AC317C5E; Thu, 28 Jun 2018 19:42:15 +0000 (UTC) From: Don Zickus To: stephen@that.guru Subject: [PATCH 1/1] parser: fix parsing of patches with headings Date: Thu, 28 Jun 2018 15:42:11 -0400 Message-Id: <20180628194211.19085-1-dzickus@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 28 Jun 2018 19:42:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 28 Jun 2018 19:42:16 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dzickus@redhat.com' RCPT:'' X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patchwork@lists.ozlabs.org, Jiri Benc MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" From: Jiri Benc 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 --- patchwork/parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patchwork/parser.py b/patchwork/parser.py index a40f931..a2db403 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -745,7 +745,7 @@ def parse_patch(content): # state specified the line we just saw, and what to expect next state = 0 # 0: text - # 1: suspected patch header (diff, ====, Index:) + # 1: suspected patch header (diff, Index:) # 2: patch header line 1 (---) # 3: patch header line 2 (+++) # 4: patch hunk header line (@@ line) @@ -753,7 +753,7 @@ def parse_patch(content): # 6: patch meta header (rename from/rename to) # # valid transitions: - # 0 -> 1 (diff, ===, Index:) + # 0 -> 1 (diff, Index:) # 0 -> 2 (---) # 1 -> 2 (---) # 2 -> 3 (+++) @@ -776,7 +776,7 @@ def parse_patch(content): line += '\n' if state == 0: - if line.startswith('diff ') or line.startswith('===') \ + if line.startswith('diff ') \ or line.startswith('Index: '): state = 1 buf += line