From 8e7da32f55eb1054716fcea1d6b0e6d08ac0c0e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 27 May 2025 11:43:45 +0200 Subject: [PATCH] =?UTF-8?q?Add=20#:create-if-missing=3F=20to=20=E2=80=98gi?= =?UTF-8?q?t-repository-url->git-repository-id=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- guix-data-service/model/git-repository.scm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/guix-data-service/model/git-repository.scm b/guix-data-service/model/git-repository.scm index f6cceb1..8fcbb43 100644 --- a/guix-data-service/model/git-repository.scm +++ b/guix-data-service/model/git-repository.scm @@ -226,7 +226,9 @@ FROM git_repositories WHERE id = $1" (string->number id)))) (define* (git-repository-url->git-repository-id conn url - #:key (authenticate? #t)) + #:key + (create-if-missing? #t) + (authenticate? #t)) (define (->boolean value) (if value "TRUE" "FALSE")) @@ -245,14 +247,15 @@ SET fetch_with_authentication = " " WHERE id = " id ";")) id) (() - (caar - (exec-query conn - (string-append - "INSERT INTO git_repositories " - "(url, fetch_with_authentication) " - "VALUES " - "('" url "', " (->boolean authenticate?) ") " - "RETURNING id")))))))) + (and create-if-missing? + (caar + (exec-query conn + (string-append + "INSERT INTO git_repositories " + "(url, fetch_with_authentication) " + "VALUES " + "('" url "', " (->boolean authenticate?) ") " + "RETURNING id"))))))))) (define (guix-revisions-and-jobs-for-git-repository conn git-repository-id) (define query