Don't hardcode the expected x-git-repo header value
Rather than expecting it always to be "guix", store the expected value in the database, and use the value of the header to find the relevant repository.
This commit is contained in:
parent
57cbac891e
commit
2f36d47b1b
6 changed files with 52 additions and 22 deletions
|
|
@ -23,9 +23,6 @@
|
||||||
#:use-module (guix-data-service jobs load-new-guix-revision)
|
#:use-module (guix-data-service jobs load-new-guix-revision)
|
||||||
#:export (enqueue-job-for-email))
|
#:export (enqueue-job-for-email))
|
||||||
|
|
||||||
(define %repository-url-for-repo
|
|
||||||
'(("guix" . "https://git.savannah.gnu.org/git/guix.git")))
|
|
||||||
|
|
||||||
(define (enqueue-job-for-email conn email)
|
(define (enqueue-job-for-email conn email)
|
||||||
(let* ((headers (email-headers email))
|
(let* ((headers (email-headers email))
|
||||||
(date (assq-ref headers 'date))
|
(date (assq-ref headers 'date))
|
||||||
|
|
@ -35,30 +32,29 @@
|
||||||
(x-git-newrev (assq-ref headers 'x-git-newrev)))
|
(x-git-newrev (assq-ref headers 'x-git-newrev)))
|
||||||
(when (and (and (string? x-git-reftype)
|
(when (and (and (string? x-git-reftype)
|
||||||
(string=? x-git-reftype "branch"))
|
(string=? x-git-reftype "branch"))
|
||||||
(and (string? x-git-repo)
|
|
||||||
(string=? x-git-repo "guix"))
|
|
||||||
(string? x-git-newrev))
|
(string? x-git-newrev))
|
||||||
|
|
||||||
(let ((branch-name
|
(let ((branch-name
|
||||||
(string-drop x-git-refname 11))
|
(string-drop x-git-refname 11))
|
||||||
(git-repository-id
|
(git-repository-id
|
||||||
(git-repository-url->git-repository-id
|
(git-repository-x-git-repo-header->git-repository-id
|
||||||
conn
|
conn
|
||||||
(assoc-ref %repository-url-for-repo x-git-repo))))
|
x-git-repo)))
|
||||||
|
|
||||||
(insert-git-branch-entry conn
|
(when git-repository-id
|
||||||
branch-name
|
(insert-git-branch-entry conn
|
||||||
(if (string=? "0000000000000000000000000000000000000000"
|
branch-name
|
||||||
x-git-newrev)
|
(if (string=? "0000000000000000000000000000000000000000"
|
||||||
""
|
x-git-newrev)
|
||||||
x-git-newrev)
|
""
|
||||||
git-repository-id
|
x-git-newrev)
|
||||||
date)
|
git-repository-id
|
||||||
|
date)
|
||||||
|
|
||||||
(unless (string=? "0000000000000000000000000000000000000000"
|
(unless (string=? "0000000000000000000000000000000000000000"
|
||||||
x-git-newrev)
|
x-git-newrev)
|
||||||
(enqueue-load-new-guix-revision-job
|
(enqueue-load-new-guix-revision-job
|
||||||
conn
|
conn
|
||||||
git-repository-id
|
git-repository-id
|
||||||
x-git-newrev
|
x-git-newrev
|
||||||
(string-append x-git-repo " " x-git-refname " updated")))))))
|
(string-append x-git-repo " " x-git-refname " updated"))))))))
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#:export (all-git-repositories
|
#:export (all-git-repositories
|
||||||
select-git-repository
|
select-git-repository
|
||||||
git-repository-id->url
|
git-repository-id->url
|
||||||
|
git-repository-x-git-repo-header->git-repository-id
|
||||||
git-repository-url->git-repository-id
|
git-repository-url->git-repository-id
|
||||||
git-repositories-containing-commit
|
git-repositories-containing-commit
|
||||||
|
|
||||||
|
|
@ -59,6 +60,17 @@
|
||||||
(list id))
|
(list id))
|
||||||
(((url)) url)))
|
(((url)) url)))
|
||||||
|
|
||||||
|
(define (git-repository-x-git-repo-header->git-repository-id conn header)
|
||||||
|
(match
|
||||||
|
(exec-query
|
||||||
|
conn
|
||||||
|
(string-append
|
||||||
|
"SELECT id FROM git_repositories WHERE x_git_repo_header = $1;")
|
||||||
|
(list header))
|
||||||
|
(() #f)
|
||||||
|
(((id))
|
||||||
|
(string->number id))))
|
||||||
|
|
||||||
(define (git-repository-url->git-repository-id conn url)
|
(define (git-repository-url->git-repository-id conn url)
|
||||||
(let ((existing-id
|
(let ((existing-id
|
||||||
(exec-query
|
(exec-query
|
||||||
|
|
|
||||||
7
sqitch/deploy/git-repositories-x-git-repo-header.sql
Normal file
7
sqitch/deploy/git-repositories-x-git-repo-header.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- Deploy guix-data-service:git-repositories-x-git-repo-header to pg
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE git_repositories ADD COLUMN x_git_repo_header varchar;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
7
sqitch/revert/git-repositories-x-git-repo-header.sql
Normal file
7
sqitch/revert/git-repositories-x-git-repo-header.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- Revert guix-data-service:git-repositories-x-git-repo-header from pg
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
ALTER TABLE git_repositories DROP COLUMN x_git_repo_header;
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
@ -42,3 +42,4 @@ derivations_hash_index 2019-12-24T22:54:19Z Christopher Baines <mail@cbaines.net
|
||||||
add_derivation_source_file_nars 2019-12-28T20:37:06Z Christopher Baines <mail@cbaines.net> # Add table for derivation source file nars
|
add_derivation_source_file_nars 2019-12-28T20:37:06Z Christopher Baines <mail@cbaines.net> # Add table for derivation source file nars
|
||||||
derivation_source_files_store_path_hash_index 2019-12-29T17:53:08Z Christopher Baines <mail@cbaines.net> # Add index on the hash part of the derivation source files store path
|
derivation_source_files_store_path_hash_index 2019-12-29T17:53:08Z Christopher Baines <mail@cbaines.net> # Add index on the hash part of the derivation source files store path
|
||||||
build_servers_build_config 2020-01-05T12:06:13Z Christopher Baines <mail@cbaines.net> # Add build_servers_build_config table
|
build_servers_build_config 2020-01-05T12:06:13Z Christopher Baines <mail@cbaines.net> # Add build_servers_build_config table
|
||||||
|
git-repositories-x-git-repo-header 2020-01-11T16:39:32Z Christopher Baines <mail@cbaines.net> # Add x_git_repo_header to git_repositories
|
||||||
|
|
|
||||||
7
sqitch/verify/git-repositories-x-git-repo-header.sql
Normal file
7
sqitch/verify/git-repositories-x-git-repo-header.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
-- Verify guix-data-service:git-repositories-x-git-repo-header on pg
|
||||||
|
|
||||||
|
BEGIN;
|
||||||
|
|
||||||
|
-- XXX Add verifications here.
|
||||||
|
|
||||||
|
ROLLBACK;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue