aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-03-14 18:04:31 +0530
committerArun Isaac2022-03-14 18:04:31 +0530
commit8c07c7eb1dadf179c51fc23e1969aacf0169b697 (patch)
tree4d585f82df1f643ef08c34be01cef813b241c3f2
parent36dbe925601d7be5dfd5c1beaa2406b1d5dbc00c (diff)
downloadguix-forge-8c07c7eb1dadf179c51fc23e1969aacf0169b697.tar.gz
guix-forge-8c07c7eb1dadf179c51fc23e1969aacf0169b697.tar.lz
guix-forge-8c07c7eb1dadf179c51fc23e1969aacf0169b697.zip
forge: Allow deep clone on derivation jobs.
* guix/forge/forge.scm (derivation-job-gexp): Accept #:deep-clone? argument and pass on to latest-git-checkout. * guix/forge/build/git.scm (download-git-to-store): Accept #:deep-clone? argument, and deep clone the git repository if it is #t. Explicitly specify the first commit to `git log' so that only the first commit message is displayed.
-rw-r--r--guix/forge/build/git.scm30
-rw-r--r--guix/forge/forge.scm13
2 files changed, 29 insertions, 14 deletions
diff --git a/guix/forge/build/git.scm b/guix/forge/build/git.scm
index 1434d07..098be83 100644
--- a/guix/forge/build/git.scm
+++ b/guix/forge/build/git.scm
@@ -40,10 +40,14 @@
(newline)
(force-output))
-(define* (download-git-to-store store name url #:key branch show-commit?)
+(define* (download-git-to-store store name url #:key branch show-commit? deep-clone?)
"Download BRANCH of git repository from URL to STORE under NAME and
return store path. If BRANCH is not specified, the default branch is
-downloaded. git and certificates should be in the environment."
+downloaded. git and certificates should be in the environment.
+
+If DEEP-CLONE? is #t, the git repository is deep cloned and the .git
+directory is included in the store. Else, the git repository is
+shallow cloned and the .git directory is not included."
(call-with-temporary-directory
(lambda (directory)
(with-directory-excursion directory
@@ -55,21 +59,25 @@ downloaded. git and certificates should be in the environment."
(invoke-error-exit-status condition))
(exit #f)))
(apply invoke
- "git" "clone" "--quiet" "--depth" "1"
- ;; Append file:// to local repository path so that
- ;; shallow clone works.
- (if (string-prefix? "/" url)
- (string-append "file://" url)
- url)
- (append (if branch
+ "git" "clone" "--quiet"
+ (append (if deep-clone?
+ (list)
+ (list "--depth" "1"))
+ ;; Append file:// to local repository path so
+ ;; that shallow clone works.
+ (list (if (string-prefix? "/" url)
+ (string-append "file://" url)
+ url))
+ (if branch
(list "--branch" branch)
(list))
(list "."))))
(when show-commit?
(hline)
- (invoke "git" "--no-pager" "log")
+ (invoke "git" "log" "HEAD~1..HEAD")
(hline))
- (delete-file-recursively ".git"))
+ (unless deep-clone?
+ (delete-file-recursively ".git")))
(add-to-store store name #t "sha256" directory))))
(define latest-git-checkout
diff --git a/guix/forge/forge.scm b/guix/forge/forge.scm
index e88edb0..f8acc80 100644
--- a/guix/forge/forge.scm
+++ b/guix/forge/forge.scm
@@ -156,15 +156,21 @@
(name (guix-module-name? name))))
(define* (derivation-job-gexp project job gexp-producer
- #:key (guix-daemon-uri (%daemon-socket-uri)))
+ #:key (guix-daemon-uri (%daemon-socket-uri)) deep-clone?)
"Return a G-expression that builds another G-expression as a
derivation and returns its output path. GEXP-PRODUCER is a
G-expression that expands to a lambda function. The lambda function
takes one argument---the latest git checkout of PROJECT, a
<forge-project> object---and returns a G-expression describing a
derivation to run. JOB is a <forge-laminar-job> object representing
-the job that this derivation will be part of. GUIX_DAEMON_URI is a
-file name or URI designating the Guix daemon endpoint."
+the job that this derivation will be part of.
+
+GUIX_DAEMON_URI is a file name or URI designating the Guix daemon
+endpoint.
+
+If DEEP-CLONE? is #t, the git checkout is a deep clone of the
+repository that includes the .git directory. Else, it is a shallow
+clone and does not include the .git directory."
(with-imported-modules (source-module-closure '((forge build git)
(guix gexp)
(guix profiles))
@@ -209,6 +215,7 @@ file name or URI designating the Guix daemon endpoint."
#$(string-append (forge-project-name project)
"-checkout")
#$(forge-project-repository project)
+ #:deep-clone? #$deep-clone?
#:show-commit? #t))
(drv (gexp->derivation #$(string-append
(forge-laminar-job-name job)