diff options
| -rw-r--r-- | Makefile.am | 1 | ||||
| -rw-r--r-- | guix/scripts/git/log.scm | 42 |
2 files changed, 32 insertions, 11 deletions
diff --git a/Makefile.am b/Makefile.am index 377cac03f78..8ce51c65a66 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -341,6 +341,7 @@ MODULES = \ | |||
| 341 | guix/scripts/size.scm \ | 341 | guix/scripts/size.scm \ |
| 342 | guix/scripts/git.scm \ | 342 | guix/scripts/git.scm \ |
| 343 | guix/scripts/git/authenticate.scm \ | 343 | guix/scripts/git/authenticate.scm \ |
| 344 | guix/scripts/git/log.scm \ | ||
| 344 | guix/scripts/graph.scm \ | 345 | guix/scripts/graph.scm \ |
| 345 | guix/scripts/weather.scm \ | 346 | guix/scripts/weather.scm \ |
| 346 | guix/scripts/container.scm \ | 347 | guix/scripts/container.scm \ |
diff --git a/guix/scripts/git/log.scm b/guix/scripts/git/log.scm index afcf28b2854..c07f3f4eb3c 100644 --- a/guix/scripts/git/log.scm +++ b/guix/scripts/git/log.scm | |||
| @@ -58,6 +58,9 @@ | |||
| 58 | (unless (member arg %formats) | 58 | (unless (member arg %formats) |
| 59 | (leave (G_ "~a: invalid format~%") arg)) | 59 | (leave (G_ "~a: invalid format~%") arg)) |
| 60 | (alist-cons 'format (string->symbol arg) result))) | 60 | (alist-cons 'format (string->symbol arg) result))) |
| 61 | (option '("grep") #t #f | ||
| 62 | (lambda (opt name arg result) | ||
| 63 | (alist-cons 'grep arg result))) | ||
| 61 | (option '("oneline") #f #f | 64 | (option '("oneline") #f #f |
| 62 | (lambda (opt name arg result) | 65 | (lambda (opt name arg result) |
| 63 | (alist-cons 'oneline? #t result))) | 66 | (alist-cons 'oneline? #t result))) |
| @@ -86,7 +89,9 @@ Show Guix commit logs.\n")) | |||
| 86 | (display (G_ " | 89 | (display (G_ " |
| 87 | --format=FORMAT show log according to FORMAT")) | 90 | --format=FORMAT show log according to FORMAT")) |
| 88 | (display (G_ " | 91 | (display (G_ " |
| 89 | --oneline show short hash and summary of five first commits")) | 92 | --grep=REGEXP show commits whose message matches REGEXP")) |
| 93 | (display (G_ " | ||
| 94 | --oneline show short hash and summary of commits")) | ||
| 90 | (display (G_ " | 95 | (display (G_ " |
| 91 | --pretty=<string> show log according to string")) | 96 | --pretty=<string> show log according to string")) |
| 92 | (newline) | 97 | (newline) |
| @@ -195,11 +200,14 @@ id instead of the 40-character one." | |||
| 195 | (let* ((channel-path (url-cache-directory (channel-url channel))) | 200 | (let* ((channel-path (url-cache-directory (channel-url channel))) |
| 196 | (repository (repository-open channel-path)) | 201 | (repository (repository-open channel-path)) |
| 197 | (latest-commit | 202 | (latest-commit |
| 198 | (commit-lookup repository (object-id (revparse-single repository "origin/master"))))) | 203 | (commit-lookup repository |
| 204 | (object-id | ||
| 205 | (revparse-single | ||
| 206 | repository "origin/master"))))) | ||
| 199 | (begin | 207 | (begin |
| 200 | (hashq-set! %channels-repositories channel-path repository) | 208 | (hashq-set! %channels-repositories channel-path repository) |
| 201 | (append (set->list (commit-closure latest-commit)) | 209 | (append (set->list (commit-closure latest-commit)) |
| 202 | commit-list)))) '() channels)) | 210 | commit-list)))) '() channels)) |
| 203 | 211 | ||
| 204 | (define (guix-git-log . args) | 212 | (define (guix-git-log . args) |
| 205 | (define options | 213 | (define options |
| @@ -208,19 +216,31 @@ id instead of the 40-character one." | |||
| 208 | (let ((channel-cache (assoc-ref options 'channel-cache-path)) | 216 | (let ((channel-cache (assoc-ref options 'channel-cache-path)) |
| 209 | (oneline? (assoc-ref options 'oneline?)) | 217 | (oneline? (assoc-ref options 'oneline?)) |
| 210 | (format-type (assoc-ref options 'format)) | 218 | (format-type (assoc-ref options 'format)) |
| 211 | (pretty-string (assoc-ref options 'pretty))) | 219 | (pretty-string (assoc-ref options 'pretty)) |
| 220 | (regexp (assoc-ref options 'grep))) | ||
| 212 | (with-error-handling | 221 | (with-error-handling |
| 213 | (cond | 222 | (cond |
| 214 | (channel-cache | 223 | (channel-cache |
| 215 | (show-channel-cache-path channel-cache)) | 224 | (show-channel-cache-path channel-cache)) |
| 216 | (oneline? | 225 | (oneline? |
| 217 | (for-each (lambda (commit-list) | 226 | (leave-on-EPIPE |
| 218 | (show-commit commit-list 'oneline #t)) | 227 | (for-each (lambda (commit) |
| 219 | (get-commits))) | 228 | (when (or (not regexp) |
| 229 | (string-match regexp (commit-message commit))) | ||
| 230 | (show-commit commit 'oneline #t))) | ||
| 231 | (get-commits)))) | ||
| 220 | (format-type | 232 | (format-type |
| 221 | (for-each (lambda (commit-list) | 233 | (leave-on-EPIPE |
| 222 | (show-commit commit-list format-type #f)) | 234 | (for-each (lambda (commit) |
| 223 | (get-commits))) | 235 | (when (or (not regexp) |
| 236 | (string-match regexp (commit-message commit))) | ||
| 237 | (show-commit commit format-type #f))) | ||
| 238 | (get-commits)))) | ||
| 224 | (pretty-string | 239 | (pretty-string |
| 225 | (let ((pretty-show (cut pretty-show-commit pretty-string <>))) | 240 | (let ((pretty-show (cut pretty-show-commit pretty-string <>))) |
| 226 | (for-each pretty-show (get-commits)))))))) | 241 | (leave-on-EPIPE |
| 242 | (for-each (lambda (commit) | ||
| 243 | (when (or (not regexp) | ||
| 244 | (string-match regexp (commit-message commit))) | ||
| 245 | (pretty-show commit))) | ||
| 246 | (get-commits))))))))) | ||
