2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/data-service.git synced 2023-12-14 03:23:03 +01:00

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.
This commit is contained in:
Christopher Baines 2020-10-04 15:12:26 +01:00
parent f68166514f
commit a8d5ea4654
2 changed files with 47 additions and 15 deletions

View file

@ -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

View file

@ -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")))))