branch: main
commit 47d8ca44ed2dc491749b125b9aa303735269b196
Author: Ludovic Courtès <l...@gnu.org>
AuthorDate: Fri Dec 20 22:01:34 2024 +0100

    templates: Display pull-request info on jobset page.
    
    * src/cuirass/http.scm (url-handler) </jobset/NAME>: Pass #:properties
    to ‘evaluation-info-table’.
    * src/cuirass/templates.scm (evaluation-info-table): Add #:properties.
    Add call to ‘pull-request-info-box’.
    (pull-request-info-box): New procedure.
---
 src/cuirass/http.scm      |  3 +++
 src/cuirass/templates.scm | 26 ++++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 0a6bfae..bcaa58e 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -1252,6 +1252,7 @@ return DEFAULT."
              (params (request-parameters request))
              (border-high (assq-ref params 'border-high))
              (border-low (assq-ref params 'border-low))
+             (spec (db-get-specification name))
              (evaluations (db-get-evaluations-build-summary name
                                                             %page-size
                                                             border-low
@@ -1270,6 +1271,8 @@ return DEFAULT."
                                 evaluations
                                 evaluation-id-min
                                 evaluation-id-max
+                                #:properties
+                                (specification-properties spec)
                                 #:active?
                                 active?
                                 #:absolute-summary
diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm
index 2f3c090..f381e2d 100644
--- a/src/cuirass/templates.scm
+++ b/src/cuirass/templates.scm
@@ -1061,11 +1061,31 @@ of build ~a (~a)"
           (broken-evaluation-badge (build-summary-evaluation-id evaluation)
                                    status))))))
 
+(define (pull-request-info-box properties)
+  "Given PROPERTIES, the property alist of a specification, return SHTML
+giving information about the corresponding pull request, if any."
+  (if (assq-ref properties 'pull-request-url)
+      `(div (@ (class "alert alert-primary"))
+            "Jobset of "
+            (a (@ (href ,(assq-ref properties 'pull-request-url)))
+               "pull request "
+               (number->string (assq-ref properties 'pull-request-number)))
+            " of "
+            (a (@ (href
+                   ,(assq-ref properties
+                              'pull-request-target-repository-home-page)))
+               ,(symbol->string
+                 (assq-ref properties
+                           'pull-request-target-repository-name)))
+            ".")
+      ""))
+
 (define* (evaluation-info-table name evaluations id-min id-max
-                                #:key (active? #t)
+                                #:key (active? #t) (properties '())
                                 absolute-summary last-update-times)
   "Return HTML for the EVALUATION table NAME, a string.  ID-MIN and ID-MAX are
-global minimal and maximal id.
+global minimal and maximal id.  PROPERTIES is an a list of properties
+associated with specification NAME.
 
 Optionally, LAST-UPDATE-TIMES is a list of times at which the repositories of
 NAME have been checked; it is #f when that information is unavailable."
@@ -1099,6 +1119,8 @@ NAME have been checked; it is #f when that information is 
unavailable."
                        (aria-hidden "true"))
                     "")))))
 
+    ,(pull-request-info-box properties)
+
     ,(if active?
          (match last-update-times
            ((time _ ...)

Reply via email to