summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagali Lemes <magalilemes00@gmail.com>2021-01-09 21:18:18 -0300
committerRicardo Wurmus <rekado@elephly.net>2022-07-04 10:34:52 +0200
commit7b912bae6f4abcaff41393bc252fab0afd8c1fe2 (patch)
tree78aa69a35988175773d635c6c07501929cf0db3f
parent99edf7e5eaf52d8fe657c706e8af8d63fa5312e4 (diff)
scripts: git: log: Manage with different channels.
* guix/scripts/git/log.scm (list-channels): New procedure. (get-commits): Retrieve commits from all channels, instead of just one. (%options): By default '--channel-cache-path' lists the paths of all channels.
-rw-r--r--guix/scripts/git/log.scm50
1 files changed, 30 insertions, 20 deletions
diff --git a/guix/scripts/git/log.scm b/guix/scripts/git/log.scm
index c5338d43a84..e1fa5a3b3a2 100644
--- a/guix/scripts/git/log.scm
+++ b/guix/scripts/git/log.scm
@@ -19,9 +19,10 @@
19(define-module (guix scripts git log) 19(define-module (guix scripts git log)
20 #:use-module (git) 20 #:use-module (git)
21 #:use-module (guix channels) 21 #:use-module (guix channels)
22 #:use-module ((guix git) #:select (url-cache-directory)) 22 #:use-module (guix git)
23 #:use-module (guix scripts) 23 #:use-module (guix scripts)
24 #:use-module (guix scripts pull) 24 #:use-module (guix scripts pull)
25 #:use-module (guix sets)
25 #:use-module (guix ui) 26 #:use-module (guix ui)
26 #:use-module (ice-9 format) 27 #:use-module (ice-9 format)
27 #:use-module (ice-9 match) 28 #:use-module (ice-9 match)
@@ -43,9 +44,10 @@
43 44
44 (option '("channel-cache-path") #f #t 45 (option '("channel-cache-path") #f #t
45 (lambda (opt name arg result) 46 (lambda (opt name arg result)
46 (alist-cons 'channel-cache-path 47 (if arg
47 (if arg (string->symbol arg) 'guix) 48 (alist-cons 'channel-cache-path
48 result))) 49 (string->symbol arg) result)
50 (list-channels))))
49 (option '("format") #t #f 51 (option '("format") #t #f
50 (lambda (opt name arg result) 52 (lambda (opt name arg result)
51 (unless (member arg %formats) 53 (unless (member arg %formats)
@@ -58,6 +60,14 @@
58(define %default-options 60(define %default-options
59 '()) 61 '())
60 62
63(define (list-channels)
64 (define channels (channel-list '()))
65 (for-each (lambda (channel)
66 (format #t "~a~% ~a~%"
67 (channel-name channel)
68 (url-cache-directory (channel-url channel))))
69 channels))
70
61(define (show-help) 71(define (show-help)
62 (display (G_ "Usage: guix git log [OPTIONS...] 72 (display (G_ "Usage: guix git log [OPTIONS...]
63Show Guix commit logs.\n")) 73Show Guix commit logs.\n"))
@@ -83,6 +93,7 @@ Show Guix commit logs.\n"))
83 (format #t "~a~%" (url-cache-directory (channel-url found-channel))) 93 (format #t "~a~%" (url-cache-directory (channel-url found-channel)))
84 (leave (G_ "~a: channel not found~%") (symbol->string channel))))) 94 (leave (G_ "~a: channel not found~%") (symbol->string channel)))))
85 95
96
86(define commit-short-id 97(define commit-short-id
87 (compose (cut string-take <> 7) oid->string commit-id)) 98 (compose (cut string-take <> 7) oid->string commit-id))
88 99
@@ -129,17 +140,18 @@ Show Guix commit logs.\n"))
129 (signature-email committer) 140 (signature-email committer)
130 (commit-message commit)))))) 141 (commit-message commit))))))
131 142
132;; returns a list of commits from path 143;; returns a list with commits from all channels
133(define (get-commits path) 144(define (get-commits)
134 (let* ((repository (repository-open path)) 145 (define channels (channel-list '()))
135 (latest-commit (commit-lookup repository (reference-target (repository-head repository))))) 146
136 (define commits (let loop ((commit latest-commit) 147 (fold (lambda (channel commit-list)
137 (res (list latest-commit))) 148 (let* ((channel-path (url-cache-directory (channel-url channel)))
138 (match (commit-parents commit) 149 (repository (repository-open channel-path))
139 (() (reverse res)) 150 (latest-commit
140 ((head . tail) 151 (commit-lookup repository(reference-target
141 (loop head (cons head res)))))) 152 (repository-head repository)))))
142 commits)) 153 (append (set->list (commit-closure latest-commit))
154 commit-list))) '() channels))
143 155
144(define (guix-git-log . args) 156(define (guix-git-log . args)
145 (define options 157 (define options
@@ -152,13 +164,11 @@ Show Guix commit logs.\n"))
152 (cond 164 (cond
153 (channel-cache 165 (channel-cache
154 (show-channel-cache-path channel-cache)) 166 (show-channel-cache-path channel-cache))
155 (oneline? 167 (oneline?
156 (let ((cache (url-cache-directory (channel-url %default-guix-channel))))
157 (for-each (lambda (commit-list) 168 (for-each (lambda (commit-list)
158 (show-commit commit-list 'oneline #t)) 169 (show-commit commit-list 'oneline #t))
159 (take (get-commits cache) 5)))) 170 (take (get-commits) 5)))
160 (format-type 171 (format-type
161 (let ((cache (url-cache-directory (channel-url %default-guix-channel))))
162 (for-each (lambda (commit-list) 172 (for-each (lambda (commit-list)
163 (show-commit commit-list format-type #f)) 173 (show-commit commit-list format-type #f))
164 (take (get-commits cache) 5)))))))) 174 (take (get-commits) 5)))))))