[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
203/285: git-authenticate: Keep a local cache of previously-authenticate
From: |
guix-commits |
Subject: |
203/285: git-authenticate: Keep a local cache of previously-authenticated commits. |
Date: |
Sun, 29 Dec 2019 20:44:30 -0500 (EST) |
kkebreau pushed a commit to branch wip-gnome3.34
in repository guix.
commit 67969e2d394a1d652507c18e66cb3e6618eda046
Author: Ludovic Courtès <address@hidden>
Date: Fri Dec 27 13:20:15 2019 +0100
git-authenticate: Keep a local cache of previously-authenticated commits.
A list of already-authenticated commits is kept in
~/.cache/guix/authentication. This speeds up subsequent "make
authenticate" invocations.
* build-aux/git-authenticate.scm (authenticated-commit-cache-file)
(previously-authenticated-commits, cache-authenticated-commit): New
procedures.
(git-authenticate): Define 'authenticated-commits' and pass it as a
third argument to 'commit-difference'. Add call to
'cache-authenticated-commit'. Don't display signing stats when STATS is
null.
---
build-aux/git-authenticate.scm | 80 ++++++++++++++++++++++++++++++++++++------
1 file changed, 70 insertions(+), 10 deletions(-)
diff --git a/build-aux/git-authenticate.scm b/build-aux/git-authenticate.scm
index dd7029d..ec67b58 100644
--- a/build-aux/git-authenticate.scm
+++ b/build-aux/git-authenticate.scm
@@ -24,6 +24,7 @@
(guix git)
(guix gnupg)
(guix utils)
+ ((guix build utils) #:select (mkdir-p))
(guix i18n)
(guix progress)
(srfi srfi-1)
@@ -31,8 +32,10 @@
(srfi srfi-26)
(srfi srfi-34)
(srfi srfi-35)
+ (rnrs io ports)
(ice-9 match)
- (ice-9 format))
+ (ice-9 format)
+ (ice-9 pretty-print))
(define %committers
@@ -297,6 +300,49 @@ each of them. Return an alist showing the number of
occurrences of each key."
;;;
+;;; Caching.
+;;;
+
+(define (authenticated-commit-cache-file)
+ "Return the name of the file that contains the cache of
+previously-authenticated commits."
+ (string-append (cache-directory) "/authentication/channels/guix"))
+
+(define (previously-authenticated-commits)
+ "Return the previously-authenticated commits as a list of commit IDs (hex
+strings)."
+ (catch 'system-error
+ (lambda ()
+ (call-with-input-file (authenticated-commit-cache-file)
+ read))
+ (lambda args
+ (if (= ENOENT (system-error-errno args))
+ '()
+ (apply throw args)))))
+
+(define (cache-authenticated-commit commit-id)
+ "Record in ~/.cache COMMIT-ID and its closure as authenticated (only
+COMMIT-ID is written to cache, though)."
+ (define %max-cache-length
+ ;; Maximum number of commits in cache.
+ 200)
+
+ (let ((lst (delete-duplicates
+ (cons commit-id (previously-authenticated-commits))))
+ (file (authenticated-commit-cache-file)))
+ (mkdir-p (dirname file))
+ (with-atomic-file-output file
+ (lambda (port)
+ (let ((lst (if (> (length lst) %max-cache-length)
+ (take lst %max-cache-length) ;truncate
+ lst)))
+ (chmod port #o600)
+ (display ";; List of previously-authenticated commits.\n\n"
+ port)
+ (pretty-print lst port))))))
+
+
+;;;
;;; Entry point.
;;;
@@ -312,8 +358,19 @@ each of them. Return an alist showing the number of
occurrences of each key."
(define end-commit
(commit-lookup repository (string->oid end)))
+ (define authenticated-commits
+ ;; Previously-authenticated commits that don't need to be checked
+ ;; again.
+ (filter-map (lambda (id)
+ (false-if-exception
+ (commit-lookup repository (string->oid id))))
+ (previously-authenticated-commits)))
+
(define commits
- (commit-difference end-commit start-commit))
+ ;; Commits to authenticate, excluding the closure of
+ ;; AUTHENTICATED-COMMITS.
+ (commit-difference end-commit start-commit
+ authenticated-commits))
(define reporter
(progress-reporter/bar (length commits)))
@@ -327,14 +384,17 @@ each of them. Return an alist showing the number of
occurrences of each key."
(lambda (report)
(authenticate-commits repository commits
#:report-progress report)))))
- (format #t (G_ "Signing statistics:~%"))
- (for-each (match-lambda
- ((signer . count)
- (format #t " ~a ~10d~%" signer count)))
- (sort stats
- (match-lambda*
- (((_ . count1) (_ . count2))
- (> count1 count2)))))))
+ (cache-authenticated-commit (oid->string (commit-id end-commit)))
+
+ (unless (null? stats)
+ (format #t (G_ "Signing statistics:~%"))
+ (for-each (match-lambda
+ ((signer . count)
+ (format #t " ~a ~10d~%" signer count)))
+ (sort stats
+ (match-lambda*
+ (((_ . count1) (_ . count2))
+ (> count1 count2))))))))
((command start)
(let* ((head (repository-head repository))
(end (reference-target head)))
- 208/285: gnu: r-delayedarray: Update to 0.12.1., (continued)
- 208/285: gnu: r-delayedarray: Update to 0.12.1., guix-commits, 2019/12/29
- 211/285: gnu: r-bibtex: Update to 0.4.2.1., guix-commits, 2019/12/29
- 213/285: gnu: r-foreign: Update to 0.8-74., guix-commits, 2019/12/29
- 162/285: build-system: linux-module: Add substitutable keyword., guix-commits, 2019/12/29
- 161/285: gnu: python-funcparserlib: Fix typo., guix-commits, 2019/12/29
- 168/285: gnu: axoloti-patcher-next: Remove commented expression., guix-commits, 2019/12/29
- 169/285: gnu: Remove squashfs-tools-next., guix-commits, 2019/12/29
- 176/285: gnu: libspatialindex: Update to 1.9.3., guix-commits, 2019/12/29
- 190/285: gnu: Add kmix., guix-commits, 2019/12/29
- 192/285: gnu: Add kwave., guix-commits, 2019/12/29
- 203/285: git-authenticate: Keep a local cache of previously-authenticated commits.,
guix-commits <=
- 155/285: gnu: nethack: Update to 3.6.4., guix-commits, 2019/12/29
- 163/285: gnu: Add zfs., guix-commits, 2019/12/29
- 160/285: gnu: python-pathos: Run test suite., guix-commits, 2019/12/29
- 167/285: gnu: guix-data-service: Update to 0.0.1-11.7342280., guix-commits, 2019/12/29
- 171/285: gnu: geos: Update to 3.8.0., guix-commits, 2019/12/29
- 181/285: download: Enable TLS 1.3., guix-commits, 2019/12/29
- 144/285: gnu: libdvbpsi: Update to 1.3.3., guix-commits, 2019/12/29
- 172/285: gnu: Add proj., guix-commits, 2019/12/29
- 179/285: gnu: gdal: Enable netCDF format driver., guix-commits, 2019/12/29
- 177/285: gnu: gdal: Enable ODS format driver., guix-commits, 2019/12/29