sup

A curses threads-with-tags style email client

sup-website.git

git clone https://supmua.dev/git/sup-website/
commit 4f2b04df62af938e80043b5acdcfcf829e61bb4c
parent 0d4ba05cae90ab6a8fa6c883acfe3649c755be23
Author: Dan Callaghan <djc@djc.id.au>
Date:   Fri,  3 Apr 2026 14:54:58 +1100

linkify commit references in stagit commit message bodies

Diffstat:
M _plugins/stagit.rb | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/_plugins/stagit.rb b/_plugins/stagit.rb
@@ -32,12 +32,20 @@ def wrap_stagit_output path, header
   stylesheet["media"] = "screen"
   doc.at("head").add_child '<link rel="icon" href="data:image/png;base64,iVBORw0KGgo=">'
 
-  ## Rewrite commit message issue references to be links
+  ## Add some nicer markup in commit messages
   doc.xpath("//pre[b[normalize-space()='commit' and not(preceding-sibling::node())]]//text()").each do |text_node|
-    rewritten = text_node.content.gsub(/(?<=^|\s)#(\d+)\b/) do |match|
+    html = text_node.content
+    ## Turn issue references into links
+    html = html.gsub(/(?<=^|\s)#(\d+)\b/) do |match|
       "<a href=\"https://github.com/sup-heliotrope/sup/issues/#{$1}\">#{$&}</a>"
     end
-    text_node.replace rewritten
+    ## Turn commit references into links
+    html = html.gsub(/(?<=[Cc]ommit )([0-9a-f]+)\b/) do |match|
+      href = Dir.new(File.dirname(path)).each_child.find { |fn| fn.start_with? $& }
+      next $& if href.nil?
+      "<a href=\"#{href}\">#{$&}</a>"
+    end
+    text_node.replace html
   end
 
   File.write(path, doc.to_html)