GNU bug report logs -
#75788
[PATCH] Bug-Reference: Allow referencing sourcehut patch series.
Previous Next
Full log
View this message in rfc822 format
* lisp/progmodes/bug-reference.el
(bug-reference--build-forge-setup-entry): Add ! syntax to reference
sourcehut patch series.
* test/lisp/progmodes/bug-reference.el (test--get-sourcehut-entry,
test-sourcehut-entry): Add procedures.
---
lisp/progmodes/bug-reference.el | 22 ++++++++++-----
test/lisp/progmodes/bug-reference-tests.el | 33 ++++++++++++++++++++++
2 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
index b25c5255f4c..7dec3b0ea0f 100644
--- a/lisp/progmodes/bug-reference.el
+++ b/lisp/progmodes/bug-reference.el
@@ -317,9 +317,10 @@ bug-reference--build-forge-setup-entry
(or (match-string-no-properties 2) ns-project)
(match-string-no-properties 3)))))))
-;; Sourcehut: #19 is an issue. Other project's issues can be
-;; referenced as ~user/project#19.
-;;
+;; Sourcehut: #19 is an issue. !19 is a patch series
+;; Other project's issues can be referenced as ~user/project#19.
+;; Other project's patch series can be referenced as ~user/project!19.
+
;; Caveat: The code assumes that a project on git.sr.ht or hg.sr.ht
;; has a tracker of the same name on todo.sh.ht. That's a very common
;; setup but all sr.ht services are loosely coupled, so you can have a
@@ -329,14 +330,21 @@ bug-reference--build-forge-setup-entry
(host-domain (_forge-type (eql 'sourcehut)) protocol)
`(,(concat "[/@]\\(?:git\\|hg\\)." (regexp-quote host-domain)
"[/:]\\(~[.A-Za-z0-9_/-]+\\)")
- "\\(\\(~[.A-Za-z0-9_/-]+\\)?\\(?:#\\)\\([0-9]+\\)\\)\\>"
+ "\\(\\(~[.A-Za-z0-9_/-]+\\)?\\([#!]\\)\\([0-9]+\\)\\)\\>"
,(lambda (groups)
(let ((ns-project (nth 1 groups)))
(lambda ()
- (format "%s://todo.%s/%s/%s"
- protocol host-domain
+ (format "%s://%s.%s/%s%s/%s"
+ protocol
+ (if (string= (match-string-no-properties 3) "#")
+ "todo"
+ "lists")
+ host-domain
(or (match-string-no-properties 2) ns-project)
- (match-string-no-properties 3)))))))
+ (if (string= (match-string-no-properties 3) "#")
+ ""
+ "/patches")
+ (match-string-no-properties 4)))))))
(defun bug-reference--setup-from-vc-alist (&optional rebuild)
"Compute the `bug-reference--setup-from-vc-alist' value.
diff --git a/test/lisp/progmodes/bug-reference-tests.el b/test/lisp/progmodes/bug-reference-tests.el
index c8e1e4a78f0..ff7f6903ab4 100644
--- a/test/lisp/progmodes/bug-reference-tests.el
+++ b/test/lisp/progmodes/bug-reference-tests.el
@@ -48,6 +48,13 @@ test--get-gitea-entry
url)
(match-string 1 url)))
+(defun test--get-sourcehut-entry (url)
+ (and (string-match
+ (car (bug-reference--build-forge-setup-entry
+ "git.sr.ht" 'sourcehut "https"))
+ url)
+ (match-string 1 url)))
+
(ert-deftest test-github-entry ()
(should
(equal
@@ -126,6 +133,32 @@ test-gitea-entry
(test--get-gitea-entry "https://gitea.com/magit/magit/")
"magit/magit")))
+(ert-deftest test-sourcehut-entry ()
+ (should
+ (equal
+ (test--get-sourcehut-entry "git <at> git.sr.ht:larsmagne/csid.git")
+ "larsmagne/csid"))
+ (should
+ (equal
+ (test--get-sourcehut-entry "git <at> git.sr.ht:larsmagne/csid")
+ "larsmagne/csid"))
+ (should
+ (equal
+ (test--get-sourcehut-entry "https://git.sr.ht/magit/magit.git")
+ "magit/magit"))
+ (should
+ (equal
+ (test--get-sourcehut-entry "https://git.sr.ht/magit/magit.git/")
+ "magit/magit"))
+ (should
+ (equal
+ (test--get-sourcehut-entry "https://git.sr.ht/magit/magit")
+ "magit/magit"))
+ (should
+ (equal
+ (test--get-sourcehut-entry "https://git.sr.ht/magit/magit/")
+ "magit/magit")))
+
(ert-deftest test-thing-at-point ()
"Ensure that (thing-at-point 'url) returns the bug URL."
(ert-with-test-buffer (:name "thingatpt")
--
2.48.1
--
Best regards,
Nicolas Graves
This bug report was last modified 93 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.