guix-commits
[Top][All Lists]
Advanced

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

02/03: Fix the no latest revision behaviour for the latest revision link


From: Christopher Baines
Subject: 02/03: Fix the no latest revision behaviour for the latest revision links
Date: Sun, 4 Oct 2020 10:38:50 -0400 (EDT)

cbaines pushed a commit to branch master
in repository data-service.

commit a8d5ea4654b2a8e429fa6e6ee0f4366bc489ded4
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Sun Oct 4 15:12:26 2020 +0100

    Fix the no latest revision behaviour for the latest revision links
    
    Previously the render-unknown-revision procedure would error, as it wasn't
    meant for this purpose.
---
 guix-data-service/web/repository/controller.scm | 48 +++++++++++++++++--------
 guix-data-service/web/repository/html.scm       | 14 +++++++-
 2 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/guix-data-service/web/repository/controller.scm 
b/guix-data-service/web/repository/controller.scm
index 84568a9..2c777de 100644
--- a/guix-data-service/web/repository/controller.scm
+++ b/guix-data-service/web/repository/controller.scm
@@ -215,8 +215,9 @@
                                  #:header-text
                                  `("Latest processed revision for branch "
                                    (samp ,branch-name)))
-           (render-unknown-revision mime-types
-                                    commit-hash))))
+           (render-no-latest-revision mime-types
+                                      repository-id
+                                      branch-name))))
     (('GET "repository" repository-id "branch" branch-name 
"latest-processed-revision" "packages")
      (letpar& ((commit-hash
                 (with-thread-postgresql-connection
@@ -255,8 +256,9 @@
                                         "/repository/" repository-id
                                         "/branch/" branch-name
                                         "/latest-processed-revision")))
-           (render-unknown-revision mime-types
-                                    commit-hash))))
+           (render-no-latest-revision mime-types
+                                      repository-id
+                                      branch-name))))
     (('GET "repository" repository-id "branch" branch-name 
"latest-processed-revision" "package-derivations")
      (letpar& ((commit-hash
                 (with-thread-postgresql-connection
@@ -287,8 +289,9 @@
                                                   commit-hash
                                                   parsed-query-parameters
                                                   #:path-base path))
-           (render-unknown-revision mime-types
-                                    commit-hash))))
+           (render-no-latest-revision mime-types
+                                      repository-id
+                                      branch-name))))
     (('GET "repository" repository-id "branch" branch-name 
"latest-processed-revision" "package-reproducibility")
      (letpar& ((commit-hash
                 (with-thread-postgresql-connection
@@ -300,8 +303,9 @@
            (render-revision-package-reproduciblity mime-types
                                                    commit-hash
                                                    #:path-base path)
-           (render-unknown-revision mime-types
-                                    commit-hash))))
+           (render-no-latest-revision mime-types
+                                      repository-id
+                                      branch-name))))
     (('GET "repository" repository-id "branch" branch-name 
"latest-processed-revision" "package-substitute-availability")
      (letpar& ((commit-hash
                 (with-thread-postgresql-connection
@@ -313,8 +317,9 @@
            (render-revision-package-substitute-availability mime-types
                                                             commit-hash
                                                             #:path-base path)
-           (render-unknown-revision mime-types
-                                    commit-hash))))
+           (render-no-latest-revision mime-types
+                                      repository-id
+                                      branch-name))))
     (('GET "repository" repository-id "branch" branch-name 
"latest-processed-revision"
            "lint-warnings")
      (letpar& ((commit-hash
@@ -348,8 +353,9 @@
                                              "/repository/" repository-id
                                              "/branch/" branch-name
                                              "/latest-processed-revision")))
-           (render-unknown-revision mime-types
-                                    commit-hash))))
+           (render-no-latest-revision mime-types
+                                      repository-id
+                                      branch-name))))
     (('GET "repository" repository-id "branch" branch-name 
"latest-processed-revision" "package" name version)
      (letpar& ((commit-hash
                 (with-thread-postgresql-connection
@@ -380,8 +386,9 @@
                                                "/repository/" repository-id
                                                "/branch/" branch-name
                                                "/package/" name))
-             (render-unknown-revision mime-types
-                                      commit-hash)))))
+             (render-no-latest-revision mime-types
+                                        repository-id
+                                        branch-name)))))
      (_ #f)))
 
 (define (parse-build-system)
@@ -395,6 +402,19 @@
           (make-invalid-query-parameter
            s "unknown system")))))
 
+(define (render-no-latest-revision mime-types git-repository-id branch-name)
+  (case (most-appropriate-mime-type
+         '(application/json text/html)
+         mime-types)
+    ((application/json)
+     (render-json
+      '((error . "no latest revision"))
+      #:code 404))
+    (else
+     (render-html
+      #:code 404
+      #:sxml (view-no-latest-revision branch-name)))))
+
 (define (render-branch-package-derivation-history request
                                                   mime-types
                                                   repository-id
diff --git a/guix-data-service/web/repository/html.scm 
b/guix-data-service/web/repository/html.scm
index f21a9f2..cc509ee 100644
--- a/guix-data-service/web/repository/html.scm
+++ b/guix-data-service/web/repository/html.scm
@@ -27,7 +27,8 @@
             view-branch
             view-branch-package
             view-branch-package-derivations
-            view-branch-package-outputs))
+            view-branch-package-outputs
+            view-no-latest-revision))
 
 (define* (view-git-repositories git-repositories)
   (layout
@@ -781,3 +782,14 @@
                                 (rationalize width 1)))))))))))
                versions-list
                outputs-by-revision-range))))))))))
+
+(define (view-no-latest-revision branch-name)
+  (layout
+   #:body
+   `(,(header)
+     (div
+      (@ (class "container"))
+      (h1 "No latest revision")
+      (p "No latest revision for "
+         (strong (samp ,branch-name))
+         " branch")))))



reply via email to

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