Extract hooks init from config

This commit is contained in:
Tom Willemse 2014-01-28 23:38:07 +01:00
parent 0272a7d17e
commit 3036734e4b

View file

@ -220,12 +220,29 @@ which no longer point to a git repository."
"Show the template specified in `global-config'." "Show the template specified in `global-config'."
(write-config global-config)) (write-config global-config))
(define-command (hooks #:optional sub repository)
"Manage your repositories' hooks."
"Usage: gitto hooks init [repository]
Installs the configured hooks into each repository or the given
repository."
(cond
((equal? sub "init")
(let ((hookwrapper
(lambda (r)
(unless (member (repo-name r) config-exclusion-list)
(install-hooks (repo-location r))))))
(if repository
(if (known? repository)
(hookwrapper (make <repository> repository))
(format #t "Unknown repository: ~a~%" repository))
(for-each hookwrapper repositories))))))
(define-command (config #:optional sub repository) (define-command (config #:optional sub repository)
"Manage your repositories' configurations." "Manage your repositories' configurations."
"Usage: gitto config "Usage: gitto config
gitto config global gitto config global
gitto config update [repository] gitto config update [repository]
gitto config hooks [repository]
The first form prints the configurations for each registered The first form prints the configurations for each registered
repository. repository.
@ -238,10 +255,7 @@ The third form merges the template in and existing configurations,
overwriting settings when necessary. The repositories in the overwriting settings when necessary. The repositories in the
`config-exclusion-list' will be skipped. If REPOSITORY is specified it `config-exclusion-list' will be skipped. If REPOSITORY is specified it
only updates the configuration for that repository. *Note:* This is a only updates the configuration for that repository. *Note:* This is a
destructive operation, you should be mindful. destructive operation, you should be mindful."
The fourth form installs the configured hooks into each repository or
the given repository."
(cond (cond
((not sub) ((not sub)
(for-each (lambda (repo) (for-each (lambda (repo)
@ -252,17 +266,7 @@ the given repository."
(newline)) (newline))
repositories)) repositories))
((equal? sub "global") (show-global-config)) ((equal? sub "global") (show-global-config))
((equal? sub "update") (update-config repository)) ((equal? sub "update") (update-config repository))))
((equal? sub "hooks")
(let ((hookwrapper
(lambda (r)
(unless (member (repo-name r) config-exclusion-list)
(install-hooks (repo-location r))))))
(if repository
(if (known? repository)
(hookwrapper (make <repository> repository))
(format #t "Unknown repository: ~a~%" repository))
(for-each hookwrapper repositories))))))
(define (update-repo-config repo) (define (update-repo-config repo)
"Merge the configured configuration with REPO's configuration. "Merge the configured configuration with REPO's configuration.