diff options
author | Christopher Baines <mail@cbaines.net> | 2020-10-04 15:12:26 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-10-04 15:12:26 +0100 |
commit | a8d5ea4654b2a8e429fa6e6ee0f4366bc489ded4 (patch) | |
tree | e41e3bf7116adbe14b929cd193cabf60c8ab3dec /guix-data-service | |
parent | f68166514f5aeea3c8af0e47c056bb7a090ee46f (diff) | |
download | data-service-a8d5ea4654b2a8e429fa6e6ee0f4366bc489ded4.tar data-service-a8d5ea4654b2a8e429fa6e6ee0f4366bc489ded4.tar.gz |
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.
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/web/repository/controller.scm | 48 | ||||
-rw-r--r-- | 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"))))) |