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.
This commit is contained in:
Tom Willemse 2013-05-25 20:22:54 +02:00
parent 8b3f0d16d3
commit 439a262ec4
2 changed files with 19 additions and 1 deletions

View file

@ -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) '())))

View file

@ -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)