aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-11-10 21:32:32 +0100
committerGravatar Tom Willemse2013-11-10 21:32:32 +0100
commit442b8f9122534e2336cfe480f6b1ced5b79cab45 (patch)
treeb417a5b03ec5bdc995d96fa2569ac4b90b48c876
parentf81fcc9a8a04d47bd1c4b158c2f1c5d592e79776 (diff)
downloadgitto-442b8f9122534e2336cfe480f6b1ced5b79cab45.tar.gz
gitto-442b8f9122534e2336cfe480f6b1ced5b79cab45.zip
Allow directory specification for config update
Add an optional directory parameter to the `config update' and `config hooks' commands, which, if specified, will limit any updates to the given repository.
-rw-r--r--gitto/main.scm37
1 files changed, 24 insertions, 13 deletions
diff --git a/gitto/main.scm b/gitto/main.scm
index 7ccfb34..f91adfa 100644
--- a/gitto/main.scm
+++ b/gitto/main.scm
@@ -220,12 +220,12 @@ which no longer point to a git repository."
"Show the template specified in `global-config'."
(write-config global-config))
-(define-command (config #:optional sub)
+(define-command (config #:optional sub repository)
"Manage your repositories' configurations."
"Usage: gitto config
gitto config global
- gitto config update
- gitto config hooks
+ gitto config update [repository]
+ gitto config hooks [repository]
The first form prints the configurations for each registered
repository.
@@ -236,10 +236,12 @@ format specifier which can be used to indicate the repository name.
The third form merges the template in and existing configurations,
overwriting settings when necessary. The repositories in the
-`config-exclusion-list' will be skipped. *Note:* This is a destructive
-operation, you should be mindful.
+`config-exclusion-list' will be skipped. If REPOSITORY is specified it
+only updates the configuration for that repository. *Note:* This is a
+destructive operation, you should be mindful.
-The fourth form installs the configured hooks into each repository."
+The fourth form installs the configured hooks into each repository or
+the given repository."
(cond
((not sub)
(for-each (lambda (repo)
@@ -250,12 +252,17 @@ The fourth form installs the configured hooks into each repository."
(newline))
repositories))
((equal? sub "global") (show-global-config))
- ((equal? sub "update") (update-config))
+ ((equal? sub "update") (update-config repository))
((equal? sub "hooks")
- (for-each (lambda (r)
- (unless (member (repo-name r) config-exclusion-list)
- (install-hooks (repo-location r))))
- repositories))))
+ (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)
"Merge the configured configuration with REPO's configuration.
@@ -268,9 +275,13 @@ Don't do anything if REPO has been added to `config-exclusion-list'."
global-config)
(string-append (repo-location repo) "/.git/config"))))
-(define (update-config)
+(define* (update-config #:optional repo)
"Merge the configured configuration with all repositories."
- (for-each update-repo-config repositories))
+ (if repo
+ (if (known? repo)
+ (update-repo-config (make <repository> repo))
+ (format #t "Unknown repository: ~a~%" repo))
+ (for-each update-repo-config repositories)))
(define (main args)
"Parse the command line options and run the appropriate functions."