From 442b8f9122534e2336cfe480f6b1ced5b79cab45 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 10 Nov 2013 21:32:32 +0100 Subject: 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. --- gitto/main.scm | 37 ++++++++++++++++++++++++------------- 1 file 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)) + (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 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." -- cgit v1.2.3-54-g00ecf