diff options
author | zimoun <zimon.toutoune@gmail.com> | 2021-11-18 01:20:23 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-12-17 17:29:34 +0100 |
commit | 28ffdc5cc815e981281e2aa67a81280666985f0f (patch) | |
tree | cd44db44037084ae5270d9fb9ff63c2ffc694ec6 /guix/scripts | |
parent | 05c962594c346da21f201be72caadfa19060cc9d (diff) |
guix hash: Add git serializer.
* 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 <ludo@gnu.org>
Diffstat (limited to 'guix/scripts')
-rw-r--r-- | guix/scripts/hash.scm | 14 |
1 files changed, 14 insertions, 0 deletions
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 @@ #: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 @@ (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 @@ use '--serializer' instead~%")) default-hash) ("nar" nar-hash) + ("git" + git-hash) (x (leave (G_ "unsupported serializer type: ~a~%") arg)))) |