[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/06: git-download: Fetch only the required commit, if possible.
From: |
Danny Milosavljevic |
Subject: |
03/06: git-download: Fetch only the required commit, if possible. |
Date: |
Sun, 4 Mar 2018 10:01:36 -0500 (EST) |
dannym pushed a commit to branch master
in repository guix.
commit 329dabe13bf98b899b907b45565434c5140804f5
Author: Danny Milosavljevic <address@hidden>
Date: Wed Feb 14 00:54:01 2018 +0100
git-download: Fetch only the required commit, if possible.
* guix/build/git.scm (git-fetch): Fetch only the required commit, if
possible.
---
guix/build/git.scm | 43 +++++++++++++++++++++++--------------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/guix/build/git.scm b/guix/build/git.scm
index c1af545..14d415a 100644
--- a/guix/build/git.scm
+++ b/guix/build/git.scm
@@ -37,28 +37,31 @@ recursively. Return #t on success, #f otherwise."
;; in advance anyway.
(setenv "GIT_SSL_NO_VERIFY" "true")
- ;; We cannot use "git clone --recursive" since the following "git checkout"
- ;; effectively removes sub-module checkouts as of Git 2.6.3.
- (and (zero? (system* git-command "clone" url directory))
- (with-directory-excursion directory
- (system* git-command "tag" "-l")
- (and (zero? (system* git-command "checkout" commit))
- (begin
- (when recursive?
- ;; Now is the time to fetch sub-modules.
- (unless (zero? (system* git-command "submodule" "update"
+ (mkdir-p directory)
+
+ (with-directory-excursion directory
+ (invoke git-command "init")
+ (invoke git-command "remote" "add" "origin" url)
+ (if (zero? (system* git-command "fetch" "--depth" "1" "origin" commit))
+ (invoke git-command "checkout" "FETCH_HEAD")
+ (begin
+ (invoke git-command "fetch" "origin")
+ (invoke git-command "checkout" commit)))
+ (when recursive?
+ ;; Now is the time to fetch sub-modules.
+ (unless (zero? (system* git-command "submodule" "update"
"--init" "--recursive"))
- (error "failed to fetch sub-modules" url))
+ (error "failed to fetch sub-modules" url))
- ;; In sub-modules, '.git' is a flat file, not a directory,
- ;; so we can use 'find-files' here.
- (for-each delete-file-recursively
- (find-files directory "^\\.git$")))
+ ;; In sub-modules, '.git' is a flat file, not a directory,
+ ;; so we can use 'find-files' here.
+ (for-each delete-file-recursively
+ (find-files directory "^\\.git$")))
- ;; The contents of '.git' vary as a function of the current
- ;; status of the Git repo. Since we want a fixed output, this
- ;; directory needs to be taken out.
- (delete-file-recursively ".git")
- #t)))))
+ ;; The contents of '.git' vary as a function of the current
+ ;; status of the Git repo. Since we want a fixed output, this
+ ;; directory needs to be taken out.
+ (delete-file-recursively ".git")
+ #t))
;;; git.scm ends here
- branch master updated (82f09c0 -> 81ed306), Danny Milosavljevic, 2018/03/04
- 04/06: gnu: python-funcy: Fix tests., Danny Milosavljevic, 2018/03/04
- 03/06: git-download: Fetch only the required commit, if possible.,
Danny Milosavljevic <=
- 05/06: gnu: abiword: Disable duplicate icon cache generation., Danny Milosavljevic, 2018/03/04
- 06/06: gnu: inkscape: Disable duplicate icon cache generation., Danny Milosavljevic, 2018/03/04
- 02/06: gnu: antlr3-3.3: Fix java8 issue., Danny Milosavljevic, 2018/03/04
- 01/06: gnu: antlr3-3.1: Fix java8 issue., Danny Milosavljevic, 2018/03/04