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))))) (sxml->html (stexi->shtml stexi)))))
(plain . ,(stexi->plain-text 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 (define (render-revision-packages mime-types
conn conn
commit-hash commit-hash
@ -552,10 +568,15 @@
(render-html (render-html
#:sxml (view-statistics (count-guix-revisions conn) #:sxml (view-statistics (count-guix-revisions conn)
(count-derivations conn)))) (count-derivations conn))))
((GET "revision" commit-hash) (render-view-revision mime-types ((GET "revision" commit-hash) (if (guix-commit-exists? conn commit-hash)
(render-view-revision mime-types
conn conn
commit-hash)) commit-hash)
(render-unknown-revision mime-types
conn
commit-hash)))
((GET "revision" commit-hash "packages") ((GET "revision" commit-hash "packages")
(if (guix-commit-exists? conn commit-hash)
(let ((parsed-query-parameters (let ((parsed-query-parameters
(guard-against-mutually-exclusive-query-parameters (guard-against-mutually-exclusive-query-parameters
(parse-query-parameters (parse-query-parameters
@ -576,13 +597,20 @@
(render-revision-packages mime-types (render-revision-packages mime-types
conn conn
commit-hash commit-hash
parsed-query-parameters))) parsed-query-parameters))
((GET "revision" commit-hash "package" name version) (render-revision-package (render-unknown-revision mime-types
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 conn
commit-hash commit-hash
name name
version)) version)
(render-unknown-revision mime-types
conn
commit-hash)))
((GET "branches") ((GET "branches")
(render-html (render-html
#:sxml (view-branches #:sxml (view-branches

View file

@ -29,6 +29,7 @@
#:use-module (texinfo html) #:use-module (texinfo html)
#:use-module (json) #:use-module (json)
#:export (index #:export (index
unknown-revision
view-statistics view-statistics
view-revision-package-and-version view-revision-package-and-version
view-revision view-revision
@ -1388,6 +1389,19 @@
(take data 2)) (take data 2))
(vlist->list target-packages-vhash)))))))))))) (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 (define (compare-unknown-commit base-commit target-commit
base-exists? target-exists? base-exists? target-exists?
base-job target-job) base-job target-job)