From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: miha--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#51316: 29.0.50; Should we match the final ".git" in bug-reference autosetup? Date: Tue, 26 Oct 2021 11:01:03 +0200 Message-ID: <87ilxkcg8g.fsf@miha-pc> References: <87ilxqbmg7.fsf@miha-pc> <87sfwtcdg5.fsf@gnus.org> <87wnm49345.fsf@gnu.org> <87o87ebos4.fsf@gnus.org> Reply-To: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31992"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 51316@debbugs.gnu.org To: Lars Ingebrigtsen , Tassilo Horn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 26 10:58:15 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mfIHf-0007zp-1W for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 10:58:15 +0200 Original-Received: from localhost ([::1]:34702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfIHd-0002gv-VU for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Oct 2021 04:58:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfIHS-0002c1-3d for bug-gnu-emacs@gnu.org; Tue, 26 Oct 2021 04:58:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33569) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mfIHR-0000kq-Qm for bug-gnu-emacs@gnu.org; Tue, 26 Oct 2021 04:58:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mfIHR-0004CF-O2 for bug-gnu-emacs@gnu.org; Tue, 26 Oct 2021 04:58:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Oct 2021 08:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51316 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 51316-submit@debbugs.gnu.org id=B51316.163523863316072 (code B ref 51316); Tue, 26 Oct 2021 08:58:01 +0000 Original-Received: (at 51316) by debbugs.gnu.org; 26 Oct 2021 08:57:13 +0000 Original-Received: from localhost ([127.0.0.1]:45115 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfIGe-0004BA-S5 for submit@debbugs.gnu.org; Tue, 26 Oct 2021 04:57:13 -0400 Original-Received: from kamnitnik.top ([209.250.245.214]:41388) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mfIGW-0004Av-Kv for 51316@debbugs.gnu.org; Tue, 26 Oct 2021 04:57:11 -0400 Original-Received: from localhost (BSN-77-156-43.static.siol.net [193.77.156.43]) by kamnitnik.top (Postfix) with ESMTPSA id 623A99CFB2; Tue, 26 Oct 2021 08:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kamnitnik.top; s=mail; t=1635238623; bh=bMiaA52i0gv2iHPmNVQNwwDkb7cpnuWWn1aOLBAT8Zw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=iG6RO9wAuaMIHuKQWBcaFMiRQVKYXq5nIXEConLkh7VvwO69F8RyE5aeTy9OI+FMJ lKSZNMdBh05RikBL/dd58Tvb55Yv3bIaXbAe6SdtANPjez3tIhzkNMFgk13Z1bOb4S oSepC7Bqi4G8VfT66Ch2q4stD3d7/A2rGg8DDatY1rkMjMp97IrxDAw4al30shkxch A7Gnpp7XNk+fROICYr70csu3y9ueTksH8gx0xtitl6Y9M8KOVO3oNYQ7IIQjJc3ZBS ylKanZoSu3QnXw2XFxX3dRps3/McHpHYDTvOg9GzvlPp8cc07vmi0yan3SKu97/c4k jKOli7N7g1Dng== In-Reply-To: <87o87ebos4.fsf@gnus.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:218364 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Tassilo Horn writes: > >> With the reasoning above, I'd suggest using >> >> "[/:]\\([.A-Za-z0-9_/-]+?\\)\\(?:\\.git/?\\)?\\'" > > Doesn't match "https://github.com/emacs-mirror/emacs/", which is what this > bug report was originally about, sort of. So I've now added a test for > this and altered the regexp to pass the test (on the trunk). Thanks. It works now for github URLs, but it should probably be used for gitlab and gitea URLs as well, patch attached. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Allow-matching-non-.git-gitlab-and-gitea-URLs-in-bug.patch Content-Transfer-Encoding: quoted-printable From=20d75c466580a5a1d6242d77d1820f6d7aa0ec4895 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Miha=3D20Rihtar=3DC5=3DA1i=3DC4=3D8D?=3D Date: Tue, 26 Oct 2021 10:54:54 +0200 Subject: [PATCH] Allow matching non-.git gitlab and gitea URLs in bug-reference * lisp/progmodes/bug-reference.el (bug-reference--build-forge-setup-entry): Allow matching non-.git gitlab and gitea URLs, with and without slashes (bug#51316). =2D-- lisp/progmodes/bug-reference.el | 4 +- test/lisp/progmodes/bug-reference-tests.el | 74 ++++++++++++++++++++-- 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference= .el index 993d670917..d7092a37d4 100644 =2D-- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -287,7 +287,7 @@ bug-reference--build-forge-setup-entry (cl-defmethod bug-reference--build-forge-setup-entry (host-domain (_forge-type (eql 'gitlab)) protocol) `(,(concat "[/@]" (regexp-quote host-domain) =2D "[/:]\\([.A-Za-z0-9_/-]+\\)\\.git") + "[/:]\\([.A-Za-z0-9_/-]+?\\)\\(?:\\.git\\)?/?\\'") "\\(\\([.A-Za-z0-9_/-]+\\)?\\([#!]\\)\\([0-9]+\\)\\)\\>" ,(lambda (groups) (let ((ns-project (nth 1 groups))) @@ -304,7 +304,7 @@ bug-reference--build-forge-setup-entry (cl-defmethod bug-reference--build-forge-setup-entry (host-domain (_forge-type (eql 'gitea)) protocol) `(,(concat "[/@]" (regexp-quote host-domain) =2D "[/:]\\([.A-Za-z0-9_/-]+\\)\\.git") + "[/:]\\([.A-Za-z0-9_/-]+?\\)\\(?:\\.git\\)?/?\\'") "\\(\\([.A-Za-z0-9_/-]+\\)?\\(?:#\\)\\([0-9]+\\)\\)\\>" ,(lambda (groups) (let ((ns-project (nth 1 groups))) diff --git a/test/lisp/progmodes/bug-reference-tests.el b/test/lisp/progmod= es/bug-reference-tests.el index 7a355509a1..7a3ab5fbda 100644 =2D-- a/test/lisp/progmodes/bug-reference-tests.el +++ b/test/lisp/progmodes/bug-reference-tests.el @@ -26,12 +26,26 @@ (require 'bug-reference) (require 'ert) =20 =2D(defun test--get-github-entry (protocol) +(defun test--get-github-entry (url) (and (string-match (car (bug-reference--build-forge-setup-entry =2D "github.com" 'github protocol)) =2D protocol) =2D (match-string 1 protocol))) + "github.com" 'github "https")) + url) + (match-string 1 url))) + +(defun test--get-gitlab-entry (url) + (and (string-match + (car (bug-reference--build-forge-setup-entry + "gitlab.com" 'gitlab "https")) + url) + (match-string 1 url))) + +(defun test--get-gitea-entry (url) + (and (string-match + (car (bug-reference--build-forge-setup-entry + "gitea.com" 'gitea "https")) + url) + (match-string 1 url))) =20 (ert-deftest test-github-entry () (should @@ -59,4 +73,56 @@ test-github-entry (test--get-github-entry "https://github.com/magit/magit/") "magit/magit"))) =20 +(ert-deftest test-gitlab-entry () + (should + (equal + (test--get-gitlab-entry "git@gitlab.com:larsmagne/csid.git") + "larsmagne/csid")) + (should + (equal + (test--get-gitlab-entry "git@gitlab.com:larsmagne/csid") + "larsmagne/csid")) + (should + (equal + (test--get-gitlab-entry "https://gitlab.com/magit/magit.git") + "magit/magit")) + (should + (equal + (test--get-gitlab-entry "https://gitlab.com/magit/magit.git/") + "magit/magit")) + (should + (equal + (test--get-gitlab-entry "https://gitlab.com/magit/magit") + "magit/magit")) + (should + (equal + (test--get-gitlab-entry "https://gitlab.com/magit/magit/") + "magit/magit"))) + +(ert-deftest test-gitea-entry () + (should + (equal + (test--get-gitea-entry "git@gitea.com:larsmagne/csid.git") + "larsmagne/csid")) + (should + (equal + (test--get-gitea-entry "git@gitea.com:larsmagne/csid") + "larsmagne/csid")) + (should + (equal + (test--get-gitea-entry "https://gitea.com/magit/magit.git") + "magit/magit")) + (should + (equal + (test--get-gitea-entry "https://gitea.com/magit/magit.git/") + "magit/magit")) + (should + (equal + (test--get-gitea-entry "https://gitea.com/magit/magit") + "magit/magit")) + (should + (equal + (test--get-gitea-entry "https://gitea.com/magit/magit/") + "magit/magit"))) + ;;; bug-reference-tests.el ends here =2D-=20 2.33.0 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJHBAEBCAAxFiEEmxVnesoT5rQXvVXnswkaGpIVmT8FAmF3w88THG1paGFAa2Ft bml0bmlrLnRvcAAKCRCzCRoakhWZP2nMD/4v9zKf9XcBx+ij7FiWX5/v/IFvshLZ 68HoNQYOkQToeK8gA91IqH2+jX77EuWCk0OeApoL3oKeKwrNRoEi4hnn0JwpHUNf spgnOOW2jluCg1axC/3UERZQnilaYtRh0gapuaLyfmSz4h+vcgd9/N0gEOv2HQ/a g906KuP1zq2B4mUVbZsRssxR+E6JEQa72voudxAzR/6t9bvbvnIajsqJst0jBKlO rpGBtQOiblRsGR6J6V9M7puXIkQj+/iC8PhYREtRrUR4Ljlvo2p6ydjdSi/E28Bv 5cStjec/9rk6H8moQs9cBP/8/WA5FbsJ9Rm/vEXxZYCx5C7n+HDP4C6kxIKmkS6Y tH0F5dixWU9B5MwKe5Yu84czmkyOjLH8pXpRsRHleSUYP12KsIt2EolajmH+UvOZ gvKU1XF3azhm1zfqhF+RBOFnA6XcBvLQnz1FwLUBrTLmi4M0GZWHmsEa3CyrBeiT nsALS/GoEyopJpGe1vwH9OR+ReDK190uXLk7s1rlkhlxajidnmnzLE7Zdga7ZJzR MP0XYhNEMB/GC4RfAJdZ3blvBaYXpsKuv13vAFd1zosTYrXJdFAnp7OxDptqVubR PcLYUPaE0KCiVDDpyMJR26MJkjDTRo0ZiXziU8ZJNornl3ekT3+QumY8T+YtSG87 G75gMrNDbXJISA== =cBtX -----END PGP SIGNATURE----- --==-=-=--