Subject: bug#75788: [PATCH] Bug-Reference: Allow referencing sourcehut patch series.

From: Nicolas Graves <[email-masked]>
Date: Thu, 23 Jan 2025 19:06:50 +0100

Tags: patch

This patch adds a way to bug-reference sourcehut patch series, which are
sometimes used rather than "todo" issues.

In GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41,
cairo version 1.18.0)
System Description: Guix System

Configured using:
 'configure
 CONFIG_SHELL=/gnu/store/m0xdsa8cfq6mq1kxgxmpmpg71la4f0b9-bash-minimal-5.1.16/bin/bash
 SHELL=/gnu/store/m0xdsa8cfq6mq1kxgxmpmpg71la4f0b9-bash-minimal-5.1.16/bin/bash
 --prefix=/gnu/store/fs9gpdns2r052dcdj8sb1a8f4cv1qb17-emacs-pgtk-29.4
 --enable-fast-install --with-pgtk --with-cairo --with-modules
 --with-native-compilation=aot --disable-build-details'

>From 8538fda01fce00561e9d22bd1a04074796aa2739 Mon Sep 17 00:00:00 2001
From: Nicolas Graves <[email-masked]>
Date: Thu, 23 Jan 2025 18:58:20 +0100
Subject: [PATCH] Bug-Reference: Allow referencing sourcehut patch series.

* lisp/progmodes/bug-reference.el
(bug-reference--build-forge-setup-entry):  Add ! syntax to reference
sourcehut patch series.
---
 lisp/progmodes/bug-reference.el | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
index 2b2858739cb..0622cb52ff6 100644
--- a/lisp/progmodes/bug-reference.el
+++ b/lisp/progmodes/bug-reference.el
@@ -317,9 +317,10 @@ via the internet it might also be http.")
                    (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 @@ via the internet it might also be http.")
   (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.
-- 
2.47.1

-- 
Best regards,
Nicolas Graves