Add an error page for unknown commits

This commit is contained in:
Christopher Baines 2019-02-08 11:27:07 +00:00
parent 0a49c0a84a
commit 552723cef1
Signed by: cbaines
GPG key ID: 5E28A33B0B84F577
3 changed files with 40 additions and 30 deletions

View file

@ -14,7 +14,8 @@
conn "SELECT id FROM guix_revisions WHERE commit = $1 LIMIT 1" conn "SELECT id FROM guix_revisions WHERE commit = $1 LIMIT 1"
(list commit)) (list commit))
(((id)) (((id))
id))) id)
(() #f)))
(define (insert-guix-revision conn url commit store_path) (define (insert-guix-revision conn url commit store_path)
(define insert (define insert

View file

@ -65,30 +65,40 @@
uri-query uri-query
parse-query-string parse-query-string
(cut assoc-ref <> "target_commit")))) (cut assoc-ref <> "target_commit"))))
(let-values (let ((base-revision-id (commit->revision-id conn base-commit))
(((base-packages-vhash target-packages-vhash) (target-revision-id (commit->revision-id conn target-commit)))
(package-data->package-data-vhashes (cond
(package-differences-data conn ((eq? base-revision-id #f)
(commit->revision-id conn base-commit)
(commit->revision-id conn target-commit)))))
(let* ((new-packages
(package-data-vhashes->new-packages base-packages-vhash
target-packages-vhash))
(removed-packages
(package-data-vhashes->removed-packages base-packages-vhash
target-packages-vhash))
(version-changes
(package-data-version-changes base-packages-vhash
target-packages-vhash))
(other-changes
(package-data-other-changes base-packages-vhash
target-packages-vhash)))
(apply render-html (apply render-html
(compare base-commit (compare-unknown-commit base-commit)))
target-commit ((eq? target-revision-id #f)
new-packages (apply render-html
removed-packages (compare-unknown-commit target-commit)))
version-changes (else
other-changes)))))) (let-values
(((base-packages-vhash target-packages-vhash)
(package-data->package-data-vhashes
(package-differences-data conn
base-revision-id
target-revision-id))))
(let* ((new-packages
(package-data-vhashes->new-packages base-packages-vhash
target-packages-vhash))
(removed-packages
(package-data-vhashes->removed-packages base-packages-vhash
target-packages-vhash))
(version-changes
(package-data-version-changes base-packages-vhash
target-packages-vhash))
(other-changes
(package-data-other-changes base-packages-vhash
target-packages-vhash)))
(apply render-html
(compare base-commit
target-commit
new-packages
removed-packages
version-changes
other-changes)))))))))
((GET path ...) ((GET path ...)
(render-static-asset request)))) (render-static-asset request))))

View file

@ -24,7 +24,7 @@
#:use-module (srfi srfi-19) #:use-module (srfi srfi-19)
#:export (index #:export (index
compare compare
unknown compare-unknown-commit
error-page)) error-page))
(define* (header) (define* (header)
@ -226,14 +226,13 @@
(td ,version)))) (td ,version))))
other-changes))))))))) other-changes)))))))))
(define (unknown id) (define (compare-unknown-commit commit)
(layout (layout
#:body #:body
`(,(header) `(,(header)
(div (@ (class "container")) (div (@ (class "container"))
(h1 "Patch not found") (h1 "Unknown commit")
(p "There is no submission with id " (strong ,id)) (p "No known revision with commit " (strong (samp ,commit)))))))
(p (a (@ (href "/")) "Try another one?"))))))
(define (error-page message) (define (error-page message)
(layout (layout