From 28ffdc5cc815e981281e2aa67a81280666985f0f Mon Sep 17 00:00:00 2001 From: zimoun Date: Thu, 18 Nov 2021 01:20:23 +0100 Subject: guix hash: Add git serializer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/hash.scm (git-hash): New procedure. (%options): Use it. * tests/guix-hash.sh: Test it. * doc/guix.texi: Update. Signed-off-by: Ludovic Courtès --- guix/scripts/hash.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'guix/scripts') diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm index debe8b4068..d73e3d13dd 100644 --- a/guix/scripts/hash.scm +++ b/guix/scripts/hash.scm @@ -35,6 +35,7 @@ (define-module (guix scripts hash) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) #:use-module (srfi srfi-37) + #:autoload (disarchive git-hash) (git-hash-file git-hash-directory) #:export (guix-hash)) @@ -60,6 +61,17 @@ (define* (default-hash file #:optional (call-with-input-file file (cute port-hash algorithm <>))))) +(define* (git-hash file #:optional + (algorithm (assoc-ref %default-options 'hash-algorithm)) + select?) + (define directory? + (case (stat:type (stat file)) + ((directory) #t) + (else #f))) + (if directory? + (git-hash-directory file algorithm) + (git-hash-file file algorithm))) + ;;; ;;; Command-line options. @@ -138,6 +150,8 @@ (define serializer-proc default-hash) ("nar" nar-hash) + ("git" + git-hash) (x (leave (G_ "unsupported serializer type: ~a~%") arg)))) -- cgit v1.2.3