From patchwork Mon Nov 11 22:27:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Ryabitsev X-Patchwork-Id: 1193167 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47BlrL0t8Gz9s4Y for ; Tue, 12 Nov 2019 09:28:02 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NyUSLrZB"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47BlrK5qq2zF14r for ; Tue, 12 Nov 2019 09:28:01 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linuxfoundation.org (client-ip=2607:f8b0:4864:20::844; helo=mail-qt1-x844.google.com; envelope-from=konstantin@linuxfoundation.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NyUSLrZB"; dkim-atps=neutral Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47Blr40rvCzF46q for ; Tue, 12 Nov 2019 09:27:47 +1100 (AEDT) Received: by mail-qt1-x844.google.com with SMTP id y10so17465898qto.3 for ; Mon, 11 Nov 2019 14:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition; bh=4IeF1Cs8EX1c1Zdvmt87oEup7VDcc9i0Rl6yQrGzATE=; b=NyUSLrZBz8s6aqZkZ//7ZB1M9r1D4AC52OtL4sRz+srM3RvITmrfs0sWFkd1GJVxUx msCVD8emJlGN4Q/uQ7UlsDZxyOrTUqb5NFHzY60M1rdqKlBacCVKQ90Ldk/FaitMSiGh n8Mg+hL64eV0J6fVTPIhzM+TKh80B2clwUCPA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :mime-version:content-disposition; bh=4IeF1Cs8EX1c1Zdvmt87oEup7VDcc9i0Rl6yQrGzATE=; b=bx8BCvzWj5vtqEHxg7Uwt9veJur4Yoq1HzhFpvIxRIpQ5MnLBdkGKEPLZyysHKViDV cNVNlfBOzoajHDfw2wdr1mgOdGpzz/qc39QhEqCOjJ1Mh+SkB9yQROt+FJfrNictyGub nJ5YTJJWZExYh9QfiTrb82mw87opKwqUkRoj4PzeMpAomNgpB5ZmdxcR7sWpql8m5a6S EKOWK0vexwHz5jwYpbr8gjRCKgvDjB7nd0/U6kjXPo2bsQ6Ohhfj7i3SqbJ4yeDnlnF+ MRrxlgGYvkJ/nF7huDxP/SCSj2GVguznQ6VXI2+fLgMIPFDnRnFdSUPyA9UUsQEXSzPa mPaQ== X-Gm-Message-State: APjAAAUjsqg2y92E2yqG3mfadNLk7HLvNDqqJthEAzTXkd7aMSeF2XFM z02U9kp4GL9HVBjyOpK8OVnXuQpl2ynqGg== X-Google-Smtp-Source: APXvYqy7x0lS/0nlcNIzPj6d8us1KquRJhimw86f0YxM32qWgFXngcnAw/2kRByTWP3Q7/e7gmyZzg== X-Received: by 2002:aed:212b:: with SMTP id 40mr28319235qtc.206.1573511263572; Mon, 11 Nov 2019 14:27:43 -0800 (PST) Received: from chatter.i7.local (107-179-243-71.cpe.teksavvy.com. [107.179.243.71]) by smtp.gmail.com with ESMTPSA id t27sm7471164qkm.19.2019.11.11.14.27.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2019 14:27:43 -0800 (PST) Date: Mon, 11 Nov 2019 17:27:41 -0500 From: Konstantin Ryabitsev To: patchwork@lists.ozlabs.org Subject: [PATCH] Improve pull request URL matching regex Message-ID: <20191111222741.u77idj6ijpljvetx@chatter.i7.local> Mail-Followup-To: patchwork@lists.ozlabs.org MIME-Version: 1.0 Content-Disposition: inline X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Existing regex was missing several important use cases, such as: - tag/branch info wrapping to the next line, e.g.: ---- are available in the Git repository at: https://git.kernel.org/pub/scm/linux/kernel/git/matthias.bgg/linux.git/ tags/v5.4-next-soc ---- (see example: https://patchwork.kernel.org/patch/11236893/) - tag/branch info being wrapped to the next line with a backslash, e.g.: ---- are available in the Git repository at: https://git.kernel.org/pub/scm/linux/kernel/git/matthias.bgg/linux.git/ \ tags/v5.4-next-soc ---- (no example, but I've seen this before) The proposed change deals with these edge-cases. Signed-off-by: Konstantin Ryabitsev --- patchwork/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) base-commit: 239fbd2ca1bf140bc61fdee922944624b23c812c diff --git a/patchwork/parser.py b/patchwork/parser.py index c794f09..d25c0df 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -939,11 +939,11 @@ def parse_patch(content): def parse_pull_request(content): git_re = re.compile(r'^The following changes since commit.*' r'^are available in the git repository at:\n' - r'^\s*([\S]+://[^\n]+)$', + r'^\s*([\w+-]+(?:://|@)[\w/.@:~-]+[\s\\]*[\w/._-]*)\s*$', re.DOTALL | re.MULTILINE | re.IGNORECASE) match = git_re.search(content) if match: - return match.group(1) + return re.sub('\s+', ' ', match.group(1)).strip() return None