diff options
author | Tom Willemse | 2013-05-25 20:22:54 +0200 |
---|---|---|
committer | Tom Willemse | 2013-05-25 20:29:33 +0200 |
commit | 439a262ec4f9f9a3dd73a69d17f3ef3765036dec (patch) | |
tree | ebe14caf9d2076f0da1bdb350d4134b8ad322d8b | |
parent | 8b3f0d16d339316428b62d3019882a778b3cc1c7 (diff) | |
download | gitto-439a262ec4f9f9a3dd73a69d17f3ef3765036dec.tar.gz gitto-439a262ec4f9f9a3dd73a69d17f3ef3765036dec.zip |
Add simple hook management
Introduces a new user configuration variable `hook-alist', which
specifies which hooks to link to which executables, for example:
,----
| (set! hook-alist '(("commit-msg" . "/path/to/my/commit/msg/hook")))
`----
With this setting the command `config hooks' will install
`/path/to/my/commit/msg/hook' to the `commit-msg' hook of each
repository not in the `config-exclusion-list' setting.
-rw-r--r-- | gitto/config.scm | 12 | ||||
-rw-r--r-- | gitto/main.scm | 8 |
2 files changed, 19 insertions, 1 deletions
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) |