[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/07: scripts: git: log: Add '--grep'.
From: |
guix-commits |
Subject: |
07/07: scripts: git: log: Add '--grep'. |
Date: |
Wed, 27 Jan 2021 09:48:53 -0500 (EST) |
magali pushed a commit to branch wip-guix-log
in repository guix.
commit 2de4bf3c2e7a59400eb45956ad6db29bfec01179
Author: Magali Lemes <magalilemes00@gmail.com>
AuthorDate: Tue Jan 19 19:21:48 2021 -0300
scripts: git: log: Add '--grep'.
* guix/scripts/git/log.scm (show-help, %options): Add '--grep'.
* Makefile.am (MODULES): Add 'guix/scripts/git/log.scm'.
---
Makefile.am | 1 +
guix/scripts/git/log.scm | 42 +++++++++++++++++++++++++++++++-----------
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 9803ba5..ebd455c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -303,6 +303,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 \
diff --git a/guix/scripts/git/log.scm b/guix/scripts/git/log.scm
index afcf28b..c07f3f4 100644
--- a/guix/scripts/git/log.scm
+++ b/guix/scripts/git/log.scm
@@ -58,6 +58,9 @@
(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 @@ Show Guix commit logs.\n"))
(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 @@ id instead of the 40-character one."
(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 @@ id instead of the 40-character one."
(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)))))))))
- branch wip-guix-log updated (b9d55a2 -> 2de4bf3), guix-commits, 2021/01/27
- 01/07: Add 'guix git log'., guix-commits, 2021/01/27
- 06/07: scripts: git: log: Add docstring., guix-commits, 2021/01/27
- 04/07: scripts: git: log: Manage with different channels., guix-commits, 2021/01/27
- 07/07: scripts: git: log: Add '--grep'.,
guix-commits <=
- 03/07: git: Export commit-closure., guix-commits, 2021/01/27
- 02/07: scripts: git: log: Add '--format'., guix-commits, 2021/01/27
- 05/07: scripts: git: log: Add '--pretty'., guix-commits, 2021/01/27