Support regexes for included and excluded branches
This commit is contained in:
parent
2043a4ef6f
commit
5d50a0e3e1
3 changed files with 30 additions and 6 deletions
|
|
@ -59,9 +59,9 @@
|
||||||
conn
|
conn
|
||||||
git-repository-id)))
|
git-repository-id)))
|
||||||
(let ((excluded-branch?
|
(let ((excluded-branch?
|
||||||
(member branch-name excluded-branches string=?))
|
(branch-in-list? excluded-branches branch-name))
|
||||||
(included-branch?
|
(included-branch?
|
||||||
(member branch-name included-branches string=?)))
|
(branch-in-list? included-branches branch-name)))
|
||||||
(when (and (not excluded-branch?)
|
(when (and (not excluded-branch?)
|
||||||
(or (null? included-branches)
|
(or (null? included-branches)
|
||||||
included-branch?))
|
included-branch?))
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
;;; <http://www.gnu.org/licenses/>.
|
;;; <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
(define-module (guix-data-service model git-repository)
|
(define-module (guix-data-service model git-repository)
|
||||||
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (json)
|
#:use-module (json)
|
||||||
#:use-module (squee)
|
#:use-module (squee)
|
||||||
|
|
@ -25,6 +26,7 @@
|
||||||
git-repository-query-substitutes?
|
git-repository-query-substitutes?
|
||||||
git-repository-id->url
|
git-repository-id->url
|
||||||
select-includes-and-excluded-branches-for-git-repository
|
select-includes-and-excluded-branches-for-git-repository
|
||||||
|
branch-in-list?
|
||||||
count-git-repositories-with-x-git-repo-header-values
|
count-git-repositories-with-x-git-repo-header-values
|
||||||
git-repository-x-git-repo-header->git-repository-id
|
git-repository-x-git-repo-header->git-repository-id
|
||||||
git-repository-url->git-repository-id
|
git-repository-url->git-repository-id
|
||||||
|
|
@ -84,6 +86,17 @@ WHERE id = $1"
|
||||||
(((url)) url)))
|
(((url)) url)))
|
||||||
|
|
||||||
(define (select-includes-and-excluded-branches-for-git-repository conn id)
|
(define (select-includes-and-excluded-branches-for-git-repository conn id)
|
||||||
|
(define (make-regexes lst)
|
||||||
|
(map
|
||||||
|
(lambda (item)
|
||||||
|
(if (string-prefix? "/" item)
|
||||||
|
(make-regexp
|
||||||
|
(string-drop
|
||||||
|
(string-drop-right item 1)
|
||||||
|
1))
|
||||||
|
item))
|
||||||
|
lst))
|
||||||
|
|
||||||
(match (exec-query
|
(match (exec-query
|
||||||
conn
|
conn
|
||||||
"
|
"
|
||||||
|
|
@ -95,11 +108,22 @@ FROM git_repositories WHERE id = $1"
|
||||||
(if (or (eq? #f included_branches)
|
(if (or (eq? #f included_branches)
|
||||||
(string-null? included_branches))
|
(string-null? included_branches))
|
||||||
'()
|
'()
|
||||||
(parse-postgresql-array-string included_branches))
|
(make-regexes
|
||||||
|
(parse-postgresql-array-string included_branches)))
|
||||||
(if (or (eq? excluded_branches #f)
|
(if (or (eq? excluded_branches #f)
|
||||||
(string-null? excluded_branches))
|
(string-null? excluded_branches))
|
||||||
'()
|
'()
|
||||||
(parse-postgresql-array-string excluded_branches))))))
|
(make-regexes
|
||||||
|
(parse-postgresql-array-string excluded_branches)))))))
|
||||||
|
|
||||||
|
(define (branch-in-list? lst branch)
|
||||||
|
(any
|
||||||
|
(lambda (item)
|
||||||
|
(->bool
|
||||||
|
(if (string? item)
|
||||||
|
(string=? item branch)
|
||||||
|
(regexp-exec item branch))))
|
||||||
|
lst))
|
||||||
|
|
||||||
(define (count-git-repositories-with-x-git-repo-header-values conn)
|
(define (count-git-repositories-with-x-git-repo-header-values conn)
|
||||||
(match (exec-query
|
(match (exec-query
|
||||||
|
|
|
||||||
|
|
@ -170,9 +170,9 @@
|
||||||
(filter
|
(filter
|
||||||
(lambda (branch-name)
|
(lambda (branch-name)
|
||||||
(let ((excluded-branch?
|
(let ((excluded-branch?
|
||||||
(member branch-name excluded-branches string=?))
|
(branch-in-list? excluded-branches branch-name))
|
||||||
(included-branch?
|
(included-branch?
|
||||||
(member branch-name included-branches string=?)))
|
(branch-in-list? included-branches branch-name)))
|
||||||
(and (not excluded-branch?)
|
(and (not excluded-branch?)
|
||||||
(or (null? included-branches)
|
(or (null? included-branches)
|
||||||
included-branch?))))
|
included-branch?))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue