@@ -55,6 +55,8 @@ (define-module (guix git-download)
git-reference-commit
git-reference-recursive?
+ git-origin
+
git-fetch
git-fetch/lfs
git-version
@@ -87,6 +89,31 @@ (define (git-lfs-package)
(let ((distro (resolve-interface '(gnu packages version-control))))
(module-ref distro 'git-lfs)))
+(define-syntax git-origin-helper
+ (syntax-rules (commit hash repository)
+ ((_ () (fields ...) c repo)
+ (origin fields ...
+ (method git-fetch)
+ (uri (git-reference (commit c)
+ (url repo)))))
+ ((_ ((commit exp) rest ...) others _ repo)
+ (git-origin-helper (rest ...) others exp repo))
+ ((_ ((hash exp) rest ...) (others ...) c repo)
+ (git-origin-helper
+ (rest ...)
+ (others ... (hash (content-hash (base32 exp) sha256)))
+ c
+ repo))
+ ((_ ((repository exp) rest ...) others c _)
+ (git-origin-helper (rest ...) others c exp))
+ ((_ (field rest ...) (others ...) c repo)
+ (git-origin-helper (rest ...) (others ... field) c repo))))
+
+(define-syntax-rule (git-origin fields ...)
+ "Build an <origin> record, converting the commit and repository field
+specifications to a <git-reference> and hash to a <content-hash>."
+ (git-origin-helper (fields ...) () #f #f))
+
(define (git-fetch-builder git git-lfs git-ref-recursive? hash-algo)
(define inputs
`(,(or git (git-package))