summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-05-11 20:33:35 +0100
committerChristopher Baines <mail@cbaines.net>2019-05-11 20:33:35 +0100
commita81a01638062adb57f770d40aebc89f4a441a49f (patch)
tree84be39381efcf4060cb1ffaf083a83c61f8fba98
parent3611f7b1225f66d8d1469d715ba5ad63a0e133cd (diff)
downloaddata-service-a81a01638062adb57f770d40aebc89f4a441a49f.tar
data-service-a81a01638062adb57f770d40aebc89f4a441a49f.tar.gz
Add a guix-commit-exists? function
-rw-r--r--guix-data-service/model/guix-revision.scm9
1 files changed, 9 insertions, 0 deletions
diff --git a/guix-data-service/model/guix-revision.scm b/guix-data-service/model/guix-revision.scm
index 6ae7693..6966bff 100644
--- a/guix-data-service/model/guix-revision.scm
+++ b/guix-data-service/model/guix-revision.scm
@@ -6,6 +6,7 @@
most-recent-n-guix-revisions
commit->revision-id
insert-guix-revision
+ guix-commit-exists?
guix-revision-exists?))
(define (count-guix-revisions conn)
@@ -36,6 +37,14 @@
(map car (exec-query conn insert)))
+(define (guix-commit-exists? conn commit)
+ (define query
+ "SELECT EXISTS(SELECT 1 FROM guix_revisions WHERE commit = $1)")
+
+ (let ((result (caar
+ (exec-query conn query (list commit)))))
+ (string=? result "t")))
+
(define (guix-revision-exists? conn git-repository-id commit)
(define query
(string-append "SELECT EXISTS("