[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#62202] [PATCH 02/21] import: utils: Change git->origin function to
From: |
Nicolas Graves |
Subject: |
[bug#62202] [PATCH 02/21] import: utils: Change git->origin function to git->origin+version. |
Date: |
Wed, 15 Mar 2023 13:51:11 +0100 |
---
guix/import/go.scm | 2 +-
guix/import/utils.scm | 50 +++++++++++++++++++++++++++----------------
2 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/guix/import/go.scm b/guix/import/go.scm
index f264715fbd..3be82ed164 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -510,7 +510,7 @@ (define* (vcs->origin vcs-type vcs-repo-url version
which takes version as an input."
(case vcs-type
((git)
- (git->origin vcs-repo-url `(tag-or-commit . ,version) transform-version))
+ (git->origin vcs-repo-url `(tag-or-commit . ,version) transform-version))
((hg)
`(origin
(method hg-fetch)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 529d7f11f8..171dca54e8 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -65,6 +65,7 @@ (define-module (guix import utils)
url-fetch
guix-hash-url
+ git->origin+dir
git->origin
package-names->package-inputs
@@ -156,9 +157,12 @@ (define (guix-hash-url filename)
"Return the hash of FILENAME in nix-base32 format."
(bytevector->nix-base32-string (file-sha256 filename)))
-(define* (git->origin repo-url ref #:optional ref->commit)
- "Generate the `origin' block of a package depending on the git source
-control system. REPO-URL or REF can be null."
+(define* (git->origin+dir repo-url ref #:optional ref->commit)
+ "Returns a generated `origin' block of a package depending on the git source
+control system, and the directory in the store where the package has been
+downloaded, in case further processing is necessary. REPO-URL or REF can be
+null. REF->COMMIT can be a function or #t, in which case the commit matching
+ref is used. If REF->COMMIT is not used, the value inside REF is used."
(let-values (((directory commit)
(with-store store
(latest-repository-commit store repo-url #:ref ref))))
@@ -172,21 +176,31 @@ (define* (git->origin repo-url ref #:optional ref->commit)
version)
(_
(ref->commit version)))))
- `(origin
- (method git-fetch)
- (uri (git-reference
- (url ,(and (not (eq? repo-url 'null)) repo-url))
- (commit ,vcommit)))
- (file-name (git-file-name name version))
- (sha256
- (base32
- ,(if (pair? ref)
- (bytevector->nix-base32-string
- (file-hash* directory
- ;; 'git-fetch' already filtered out the '.git'
directory.
- #:select? (const #true)
- #:recursive? #true))
- #f)))))))
+ (values
+ `(origin
+ (method git-fetch)
+ (uri (git-reference
+ (url ,(and (not (eq? repo-url 'null)) repo-url))
+ (commit ,vcommit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ ,(if (pair? ref)
+ (bytevector->nix-base32-string
+ (file-hash* directory
+ ;; 'git-fetch' already filtered out the '.git'
directory.
+ #:select? (const #true)
+ #:recursive? #true))
+ #f))))
+ directory))))
+
+(define* (git->origin repo-url ref #:optional ref->commit)
+ "Returns a generated `origin' block of a package depending on the git source
+control system. REPO-URL or REF can be null. REF->COMMIT can be a function or
+#t, in which case the commit matching ref is used. If REF->COMMIT is not used,
+the value inside REF is used."
+ (let-values (((origin _) (git->origin+dir repo-url ref ref->commit)))
+ origin))
(define %spdx-license-identifiers
;; https://spdx.org/licenses/
--
2.39.2
- [bug#62202] [PATCH 0/21] Juliahub import script., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 01/21] import: juliahub: first script draft., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 02/21] import: utils: Change git->origin function to git->origin+version.,
Nicolas Graves <=
- [bug#62202] [PATCH 04/21] import: juliahub: Correct source parsing., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 03/21] import: juliahub: Add support for native-inputs., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 11/21] import: juliahub: Improve test dependencies parsing., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 09/21] import: juliahub: Improve dependency management., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 06/21] import: juliahub: Add updater and recursive-importer., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 05/21] import: juliahub: Add indirect dependencies., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 08/21] import: juliahub: Simplify juliahub dependency management., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 10/21] import: juliahub: Add functions to parse the git repo for a git tag., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 07/21] import: juliahub: Filter out julia stdlibs., Nicolas Graves, 2023/03/15
- [bug#62202] [PATCH 12/21] import: juliahub: Handle the case where we have a subdirectory., Nicolas Graves, 2023/03/15