diff --git a/gitto/config.scm b/gitto/config.scm index dcaecf0..6726e66 100644 --- a/gitto/config.scm +++ b/gitto/config.scm @@ -21,12 +21,24 @@ #:use-module (ice-9 format) #:use-module (ice-9 rdelim) #:export (global-config + hook-alist + install-hooks merge-config read-config write-config)) (define global-config '()) +(define hook-alist '()) + +(define (install-hooks repo-location) + (for-each + (lambda (hook) + (let ((new-name (string-append repo-location "/.git/hooks/" + (car hook)))) + (unless (file-exists? new-name) + (symlink (cdr hook) new-name)))) + hook-alist)) (define (merge-config repo-name x y) (let ((lst (if x (list-copy x) '()))) diff --git a/gitto/main.scm b/gitto/main.scm index c162a10..7cb98a9 100644 --- a/gitto/main.scm +++ b/gitto/main.scm @@ -65,6 +65,7 @@ gitto [command [arguments ...]] config global Show template configuration config update Merge template configuration with each repository's configuration + config hooks Install configured hooks for repositories version Display version help Display this help ")) @@ -180,7 +181,12 @@ gitto [command [arguments ...]] (newline)) repositories)) ((equal? (car args) "global") (show-global-config)) - ((equal? (car args) "update") (update-config)))) + ((equal? (car args) "update") (update-config)) + ((equal? (car args) "hooks") + (for-each (lambda (r) + (unless (member (repo-name r) config-exclusion-list) + (install-hooks (repo-location r)))) + repositories)))) (set! command-list (append command-list `(("config" . ,show-config)))) (define (update-repo-config repo)