diff options
6 files changed, 70 insertions, 15 deletions
diff --git a/guix-data-service/branch-updated-emails.scm b/guix-data-service/branch-updated-emails.scm index e367d94..bec9b33 100644 --- a/guix-data-service/branch-updated-emails.scm +++ b/guix-data-service/branch-updated-emails.scm @@ -16,6 +16,8 @@ ;;; <http://www.gnu.org/licenses/>. (define-module (guix-data-service branch-updated-emails) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-11) #:use-module (srfi srfi-19) #:use-module (email email) #:use-module (guix-data-service model git-repository) @@ -42,19 +44,31 @@ x-git-repo))) (when git-repository-id - (insert-git-branch-entry conn - branch-name - (if (string=? "0000000000000000000000000000000000000000" - x-git-newrev) - "" - x-git-newrev) - git-repository-id - date) + (let-values + (((included-branches excluded-branches) + (select-includes-and-excluded-branches-for-git-repository + conn + git-repository-id))) + (let ((excluded-branch? + (member branch-name excluded-branches string=?)) + (included-branch? + (member branch-name included-branches string=?))) + (when (and (not excluded-branch?) + (or (null? included-branches) + included-branch?)) + (insert-git-branch-entry conn + branch-name + (if (string=? "0000000000000000000000000000000000000000" + x-git-newrev) + "" + x-git-newrev) + git-repository-id + date) - (unless (string=? "0000000000000000000000000000000000000000" - x-git-newrev) - (enqueue-load-new-guix-revision-job - conn - git-repository-id - x-git-newrev - (string-append x-git-repo " " x-git-refname " updated")))))))) + (unless (string=? "0000000000000000000000000000000000000000" + x-git-newrev) + (enqueue-load-new-guix-revision-job + conn + git-repository-id + x-git-newrev + (string-append x-git-repo " " x-git-refname " updated"))))))))))) diff --git a/guix-data-service/model/git-repository.scm b/guix-data-service/model/git-repository.scm index 6873ab6..8639644 100644 --- a/guix-data-service/model/git-repository.scm +++ b/guix-data-service/model/git-repository.scm @@ -19,9 +19,11 @@ #:use-module (ice-9 match) #:use-module (json) #:use-module (squee) + #:use-module (guix-data-service model utils) #:export (all-git-repositories select-git-repository git-repository-id->url + select-includes-and-excluded-branches-for-git-repository count-git-repositories-with-x-git-repo-header-values git-repository-x-git-repo-header->git-repository-id git-repository-url->git-repository-id @@ -61,6 +63,22 @@ (list id)) (((url)) url))) +(define (select-includes-and-excluded-branches-for-git-repository conn id) + (match (exec-query + conn + " +SELECT included_branches, excluded_branches +FROM git_repositories WHERE id = $1" + (list (number->string id))) + (((included_branches excluded_branches)) + (values + (if (string=? included_branches "") + '() + (parse-postgresql-array-string included_branches)) + (if (string=? excluded_branches "") + '() + (parse-postgresql-array-string excluded_branches)))))) + (define (count-git-repositories-with-x-git-repo-header-values conn) (match (exec-query conn diff --git a/sqitch/deploy/allow_including_and_excluding_branches_for_repositories.sql b/sqitch/deploy/allow_including_and_excluding_branches_for_repositories.sql new file mode 100644 index 0000000..37c98ad --- /dev/null +++ b/sqitch/deploy/allow_including_and_excluding_branches_for_repositories.sql @@ -0,0 +1,8 @@ +-- Deploy guix-data-service:allow_including_and_excluding_branches_for_repositories to pg + +BEGIN; + +ALTER TABLE git_repositories ADD COLUMN included_branches varchar[]; +ALTER TABLE git_repositories ADD COLUMN excluded_branches varchar[]; + +COMMIT; diff --git a/sqitch/revert/allow_including_and_excluding_branches_for_repositories.sql b/sqitch/revert/allow_including_and_excluding_branches_for_repositories.sql new file mode 100644 index 0000000..5a89181 --- /dev/null +++ b/sqitch/revert/allow_including_and_excluding_branches_for_repositories.sql @@ -0,0 +1,7 @@ +-- Revert guix-data-service:allow_including_and_excluding_branches_for_repositories from pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan index 2d04104..6eabcc1 100644 --- a/sqitch/sqitch.plan +++ b/sqitch/sqitch.plan @@ -48,3 +48,4 @@ change_package_derivations_target 2020-02-07T19:29:50Z Christopher Baines <mail@ remove_old_cross_derivations 2020-02-07T19:42:54Z Christopher Baines <mail@cbaines.net> # Remove old cross derivations increase_fillfactor_for_some_indexes 2020-02-07T20:49:17Z Christopher Baines <mail@cbaines.net> # Increase the fillfactor for some btree indexes change_package_derivations_by_guix_revision_range_target 2020-02-08T10:13:07Z Christopher Baines <mail@cbaines.net> # Change the values for package_derivations_by_guix_revision_range target +allow_including_and_excluding_branches_for_repositories 2020-02-08T11:30:02Z Christopher Baines <mail@cbaines.net> # Allow including and excluding branches for repositories diff --git a/sqitch/verify/allow_including_and_excluding_branches_for_repositories.sql b/sqitch/verify/allow_including_and_excluding_branches_for_repositories.sql new file mode 100644 index 0000000..fbec379 --- /dev/null +++ b/sqitch/verify/allow_including_and_excluding_branches_for_repositories.sql @@ -0,0 +1,7 @@ +-- Verify guix-data-service:allow_including_and_excluding_branches_for_repositories on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; |