guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/11: git-authenticate: Cache takes a key parameter.


From: guix-commits
Subject: 02/11: git-authenticate: Cache takes a key parameter.
Date: Tue, 16 Jun 2020 10:16:09 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit a450b4343bc1e5284c4db6409976eba7bb92df19
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Jun 8 11:50:57 2020 +0200

    git-authenticate: Cache takes a key parameter.
    
    * guix/git-authenticate.scm (authenticated-commit-cache-file)
    (cache-authenticated-commit, previously-authenticated-commits): Add
    'key' parameter and honor it.
    * build-aux/git-authenticate.scm (git-authenticate): Pass
    "channels/guix" as the key.
---
 build-aux/git-authenticate.scm |  5 +++--
 guix/git-authenticate.scm      | 24 ++++++++++++------------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/build-aux/git-authenticate.scm b/build-aux/git-authenticate.scm
index 5e1fdaa..a3d4b40 100644
--- a/build-aux/git-authenticate.scm
+++ b/build-aux/git-authenticate.scm
@@ -252,7 +252,7 @@
          (filter-map (lambda (id)
                        (false-if-exception
                         (commit-lookup repository (string->oid id))))
-                     (previously-authenticated-commits)))
+                     (previously-authenticated-commits "channels/guix")))
 
        (define commits
          ;; Commits to authenticate, excluding the closure of
@@ -274,7 +274,8 @@
                                               #:default-authorizations
                                               
%historical-authorized-signing-keys
                                               #:report-progress report)))))
-         (cache-authenticated-commit (oid->string (commit-id end-commit)))
+         (cache-authenticated-commit "channels/guix"
+                                     (oid->string (commit-id end-commit)))
 
          (unless (null? stats)
            (format #t (G_ "Signing statistics:~%"))
diff --git a/guix/git-authenticate.scm b/guix/git-authenticate.scm
index 0d6f696..cdb54a0 100644
--- a/guix/git-authenticate.scm
+++ b/guix/git-authenticate.scm
@@ -295,33 +295,33 @@ The OpenPGP keyring is loaded from KEYRING-REFERENCE in 
REPOSITORY."
 ;;; Caching.
 ;;;
 
-(define (authenticated-commit-cache-file)
+(define (authenticated-commit-cache-file key)
   "Return the name of the file that contains the cache of
-previously-authenticated commits."
-  (string-append (cache-directory) "/authentication/channels/guix"))
+previously-authenticated commits for KEY."
+  (string-append (cache-directory) "/authentication/" key))
 
-(define (previously-authenticated-commits)
-  "Return the previously-authenticated commits as a list of commit IDs (hex
-strings)."
+(define (previously-authenticated-commits key)
+  "Return the previously-authenticated commits under KEY as a list of commit
+IDs (hex strings)."
   (catch 'system-error
     (lambda ()
-      (call-with-input-file (authenticated-commit-cache-file)
+      (call-with-input-file (authenticated-commit-cache-file key)
         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 (cache-authenticated-commit key commit-id)
+  "Record in ~/.cache, under KEY, 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)))
+               (cons commit-id (previously-authenticated-commits key))))
+        (file (authenticated-commit-cache-file key)))
     (mkdir-p (dirname file))
     (with-atomic-file-output file
       (lambda (port)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]