Add missing revision handling

As previously the pages would render, but with no data.
This commit is contained in:
Christopher Baines 2019-05-19 22:31:07 +01:00
parent cc0ecdc055
commit 6add08b109
2 changed files with 71 additions and 29 deletions

View file

@ -131,6 +131,22 @@
(sxml->html (stexi->shtml stexi)))))
(plain . ,(stexi->plain-text stexi)))))
(define (render-unknown-revision mime-types conn commit-hash)
(case (most-appropriate-mime-type
'(application/json text/html)
mime-types)
((application/json)
(render-json
'((unknown_commit . ,commit-hash))
#:code 404))
(else
(render-html
#:code 404
#:sxml (unknown-revision
commit-hash
(select-job-for-commit
conn commit-hash))))))
(define (render-revision-packages mime-types
conn
commit-hash
@ -552,37 +568,49 @@
(render-html
#:sxml (view-statistics (count-guix-revisions conn)
(count-derivations conn))))
((GET "revision" commit-hash) (render-view-revision mime-types
conn
commit-hash))
((GET "revision" commit-hash) (if (guix-commit-exists? conn commit-hash)
(render-view-revision mime-types
conn
commit-hash)
(render-unknown-revision mime-types
conn
commit-hash)))
((GET "revision" commit-hash "packages")
(let ((parsed-query-parameters
(guard-against-mutually-exclusive-query-parameters
(parse-query-parameters
request
`((after_name ,identity)
(field ,identity #:multi-value
#:default ("version" "synopsis"))
(search_query ,identity)
(limit_results ,parse-result-limit
#:no-default-when (all_results)
#:default 100)
(all_results ,parse-checkbox-value)))
;; You can't specify a search query, but then also limit the
;; results by filtering for after a particular package name
'((after_name search_query)
(limit_results all_results)))))
(if (guix-commit-exists? conn commit-hash)
(let ((parsed-query-parameters
(guard-against-mutually-exclusive-query-parameters
(parse-query-parameters
request
`((after_name ,identity)
(field ,identity #:multi-value
#:default ("version" "synopsis"))
(search_query ,identity)
(limit_results ,parse-result-limit
#:no-default-when (all_results)
#:default 100)
(all_results ,parse-checkbox-value)))
;; You can't specify a search query, but then also limit the
;; results by filtering for after a particular package name
'((after_name search_query)
(limit_results all_results)))))
(render-revision-packages mime-types
conn
commit-hash
parsed-query-parameters)))
((GET "revision" commit-hash "package" name version) (render-revision-package
mime-types
conn
commit-hash
name
version))
(render-revision-packages mime-types
conn
commit-hash
parsed-query-parameters))
(render-unknown-revision mime-types
conn
commit-hash)))
((GET "revision" commit-hash "package" name version)
(if (guix-commit-exists? conn commit-hash)
(render-revision-package mime-types
conn
commit-hash
name
version)
(render-unknown-revision mime-types
conn
commit-hash)))
((GET "branches")
(render-html
#:sxml (view-branches

View file

@ -29,6 +29,7 @@
#:use-module (texinfo html)
#:use-module (json)
#:export (index
unknown-revision
view-statistics
view-revision-package-and-version
view-revision
@ -1388,6 +1389,19 @@
(take data 2))
(vlist->list target-packages-vhash))))))))))))
(define (unknown-revision commit-hash job)
(layout
#:body
`(,(header)
(div
(@ (class "container"))
(h1 "Unknown revision")
(p "No known revision with commit "
(strong (samp ,commit-hash))
,(if job
" and it is not currently queued for processing"
" but it is queued for processing"))))))
(define (compare-unknown-commit base-commit target-commit
base-exists? target-exists?
base-job target-job)