guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Ludovic Courtès
Date: Wed, 18 Oct 2023 09:04:25 -0400 (EDT)

branch: master
commit cc31d2862110be2c3762e5a0f4a7b38b3012869e
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Oct 18 14:55:31 2023 +0200

    templates: ‘commit-hyperlink’ can display shortened commit IDs.
    
    * src/cuirass/templates.scm (commit-hyperlink): Add #:shorten?
    parameter, and honor it.
---
 src/cuirass/templates.scm | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm
index a628e58..17d7cab 100644
--- a/src/cuirass/templates.scm
+++ b/src/cuirass/templates.scm
@@ -1263,15 +1263,19 @@ and BUILD-MAX are global minimal and maximal (stoptime, 
rowid) pairs."
       ("gitlab.inria.fr" ,labhub-url)
       ("github.com" ,labhub-url))))
 
-(define (commit-hyperlink url commit)
-  "Return, if possibly, a hyperlink for COMMIT of the repository at URL."
-  (match (string->uri url)
-    (#f commit)
-    (uri
-     (let ((host (uri-host uri)))
-       (match (assoc-ref %vcs-web-views host)
-         (#f     commit)
-         ((link) `(a (@ (href ,(link url commit))) ,commit)))))))
+(define* (commit-hyperlink url commit #:key shorten?)
+  "Return, if possibly, a hyperlink for COMMIT of the repository at URL.  When
+SHORTEN? is true, display a shortened version of COMMIT."
+  (let ((str (if shorten?
+                 (string-take commit 7)
+                 commit)))
+    (match (string->uri url)
+      (#f str)
+      (uri
+       (let ((host (uri-host uri)))
+         (match (assoc-ref %vcs-web-views host)
+           (#f     str)
+           ((link) `(a (@ (href ,(link url commit))) ,str))))))))
 
 (define (nearest-exact-integer x)
   "Given a real number X, return the nearest exact integer, with ties going to



reply via email to

[Prev in Thread] Current Thread [Next in Thread]