guix-patches
[Top][All Lists]
Advanced

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

[bug#73126] [PATCH v2 1/2] download: Add git-source.


From: Herman Rimm
Subject: [bug#73126] [PATCH v2 1/2] download: Add git-source.
Date: Mon, 16 Sep 2024 18:29:57 +0200

* guix/git-download.scm (git-source): Add and export procedure.
* doc/guix.texi (origin Reference): Document git-source.

Change-Id: I40c24ff10135e4895c5319f969005ba1c09760db
---
 doc/guix.texi         |  7 +++++++
 guix/git-download.scm | 12 +++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index bc4d306c2d..fa64c6a3fc 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8248,6 +8248,13 @@ origin Reference
 @end lisp
 @end deftp
 
+@deffn {Procedure} git-source hash host author project commit [prefix]
+Return an @code{origin} corresponding to the @var{host}'s repository for
+the @var{author}'s @var{project}.  It is checked out at @var{commit},
+with a consistent @var{prefix} used in some repositories.  @var{hash} is
+the string for a base32-encoded SHA256 hash used by @code{git-fetch}.
+@end deffn
+
 For Mercurial repositories, the module @code{(guix hg-download)} defines
 the @code{hg-fetch} origin method and @code{hg-reference} data type for
 support of the Mercurial version control system.
diff --git a/guix/git-download.scm b/guix/git-download.scm
index ae2073ea06..6de53fec70 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -59,7 +59,8 @@ (define-module (guix git-download)
             git-fetch/lfs
             git-version
             git-file-name
-            git-predicate))
+            git-predicate
+            git-source))
 
 ;;; Commentary:
 ;;;
@@ -395,4 +396,13 @@ (define* (git-predicate directory #:key (recursive? #t))
             (#f        #f)))))
     (const #f)))
 
+(define* (git-source hash host author project commit #:optional prefix)
+  (origin
+    (method git-fetch)
+    (uri (git-reference
+           (url (string-join (list "https:/" host author project) "/"))
+           (commit (if prefix (string-append prefix commit) commit))))
+    (file-name (git-file-name project commit))
+    (hash (content-hash (base32 hash) sha256))))
+
 ;;; git-download.scm ends here
-- 
2.45.2






reply via email to

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