mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-18 13:36:36 +01:00
scripts: git: log: Add '--grep'.
* guix/scripts/git/log.scm (show-help, %options): Add '--grep'. * Makefile.am (MODULES): Add 'guix/scripts/git/log.scm'.
This commit is contained in:
parent
754157f50b
commit
c215307e0c
2 changed files with 32 additions and 11 deletions
|
@ -341,6 +341,7 @@ MODULES = \
|
|||
guix/scripts/size.scm \
|
||||
guix/scripts/git.scm \
|
||||
guix/scripts/git/authenticate.scm \
|
||||
guix/scripts/git/log.scm \
|
||||
guix/scripts/graph.scm \
|
||||
guix/scripts/weather.scm \
|
||||
guix/scripts/container.scm \
|
||||
|
|
|
@ -58,6 +58,9 @@ (define %options
|
|||
(unless (member arg %formats)
|
||||
(leave (G_ "~a: invalid format~%") arg))
|
||||
(alist-cons 'format (string->symbol arg) result)))
|
||||
(option '("grep") #t #f
|
||||
(lambda (opt name arg result)
|
||||
(alist-cons 'grep arg result)))
|
||||
(option '("oneline") #f #f
|
||||
(lambda (opt name arg result)
|
||||
(alist-cons 'oneline? #t result)))
|
||||
|
@ -86,7 +89,9 @@ (define (show-help)
|
|||
(display (G_ "
|
||||
--format=FORMAT show log according to FORMAT"))
|
||||
(display (G_ "
|
||||
--oneline show short hash and summary of five first commits"))
|
||||
--grep=REGEXP show commits whose message matches REGEXP"))
|
||||
(display (G_ "
|
||||
--oneline show short hash and summary of commits"))
|
||||
(display (G_ "
|
||||
--pretty=<string> show log according to string"))
|
||||
(newline)
|
||||
|
@ -195,11 +200,14 @@ (define channels (channel-list '()))
|
|||
(let* ((channel-path (url-cache-directory (channel-url channel)))
|
||||
(repository (repository-open channel-path))
|
||||
(latest-commit
|
||||
(commit-lookup repository (object-id (revparse-single repository "origin/master")))))
|
||||
(commit-lookup repository
|
||||
(object-id
|
||||
(revparse-single
|
||||
repository "origin/master")))))
|
||||
(begin
|
||||
(hashq-set! %channels-repositories channel-path repository)
|
||||
(append (set->list (commit-closure latest-commit))
|
||||
commit-list)))) '() channels))
|
||||
commit-list)))) '() channels))
|
||||
|
||||
(define (guix-git-log . args)
|
||||
(define options
|
||||
|
@ -208,19 +216,31 @@ (define options
|
|||
(let ((channel-cache (assoc-ref options 'channel-cache-path))
|
||||
(oneline? (assoc-ref options 'oneline?))
|
||||
(format-type (assoc-ref options 'format))
|
||||
(pretty-string (assoc-ref options 'pretty)))
|
||||
(pretty-string (assoc-ref options 'pretty))
|
||||
(regexp (assoc-ref options 'grep)))
|
||||
(with-error-handling
|
||||
(cond
|
||||
(channel-cache
|
||||
(show-channel-cache-path channel-cache))
|
||||
(oneline?
|
||||
(for-each (lambda (commit-list)
|
||||
(show-commit commit-list 'oneline #t))
|
||||
(get-commits)))
|
||||
(leave-on-EPIPE
|
||||
(for-each (lambda (commit)
|
||||
(when (or (not regexp)
|
||||
(string-match regexp (commit-message commit)))
|
||||
(show-commit commit 'oneline #t)))
|
||||
(get-commits))))
|
||||
(format-type
|
||||
(for-each (lambda (commit-list)
|
||||
(show-commit commit-list format-type #f))
|
||||
(get-commits)))
|
||||
(leave-on-EPIPE
|
||||
(for-each (lambda (commit)
|
||||
(when (or (not regexp)
|
||||
(string-match regexp (commit-message commit)))
|
||||
(show-commit commit format-type #f)))
|
||||
(get-commits))))
|
||||
(pretty-string
|
||||
(let ((pretty-show (cut pretty-show-commit pretty-string <>)))
|
||||
(for-each pretty-show (get-commits))))))))
|
||||
(leave-on-EPIPE
|
||||
(for-each (lambda (commit)
|
||||
(when (or (not regexp)
|
||||
(string-match regexp (commit-message commit)))
|
||||
(pretty-show commit)))
|
||||
(get-commits)))))))))
|
||||
|
|
Loading…
Reference in a new issue