@@ -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.
@@ -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