Commit 5a0c79ab authored by Eric Timmons's avatar Eric Timmons
Browse files

Make repo fetching respect local flag on bundle commands

parent abbb9ad0
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#:clpm/context #:clpm/context
#:clpm/install #:clpm/install
#:clpm/log #:clpm/log
#:clpm/repos
#:clpm/resolve #:clpm/resolve
#:clpm/source) #:clpm/source)
(:export #:bundle-install (:export #:bundle-install
...@@ -51,7 +52,8 @@ ...@@ -51,7 +52,8 @@
(defun bundle-install (clpmfile-designator &key localp (validate (constantly t))) (defun bundle-install (clpmfile-designator &key localp (validate (constantly t)))
"Given a clpmfile instance, install all releases from its lock file, creating "Given a clpmfile instance, install all releases from its lock file, creating
the lock file if necessary." the lock file if necessary."
(let* ((clpmfile (get-clpmfile clpmfile-designator)) (let* ((*fetch-repo-automatically* (not localp))
(clpmfile (get-clpmfile clpmfile-designator))
(lockfile-pathname (clpmfile-lockfile-pathname clpmfile)) (lockfile-pathname (clpmfile-lockfile-pathname clpmfile))
(lockfile nil) (lockfile nil)
(changedp nil)) (changedp nil))
...@@ -75,7 +77,8 @@ the lock file if necessary." ...@@ -75,7 +77,8 @@ the lock file if necessary."
update-projects (validate (constantly t)) update-projects (validate (constantly t))
update-systems update-systems
localp) localp)
(let* ((clpmfile (get-clpmfile clpmfile-designator)) (let* ((*fetch-repo-automatically* (not localp))
(clpmfile (get-clpmfile clpmfile-designator))
(lockfile-pathname (clpmfile-lockfile-pathname clpmfile)) (lockfile-pathname (clpmfile-lockfile-pathname clpmfile))
(lockfile nil) (lockfile nil)
(changedp nil)) (changedp nil))
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
(uiop:define-package #:clpm/repos/defs (uiop:define-package #:clpm/repos/defs
(:use #:cl) (:use #:cl)
(:export #:ensure-ref-present-locally! (:export #:*fetch-repo-automatically*
#:ensure-ref-present-locally!
#:ref-present-p #:ref-present-p
#:repo-archive-stream #:repo-archive-stream
#:repo-lib-base-pathname #:repo-lib-base-pathname
...@@ -15,6 +16,8 @@ ...@@ -15,6 +16,8 @@
(in-package #:clpm/repos/defs) (in-package #:clpm/repos/defs)
(defvar *fetch-repo-automatically* t)
(defgeneric ensure-ref-present-locally! (repo ref)) (defgeneric ensure-ref-present-locally! (repo ref))
(defgeneric ref-present-p (repo ref)) (defgeneric ref-present-p (repo ref))
......
...@@ -218,22 +218,28 @@ ref is present locally, fetching or cloning the repo as necessary." ...@@ -218,22 +218,28 @@ ref is present locally, fetching or cloning the repo as necessary."
(destructuring-bind (ref-type ref-name) ref (destructuring-bind (ref-type ref-name) ref
(declare (ignore ref-name)) (declare (ignore ref-name))
(let ((local-dir (git-repo-local-dir repo))) (let ((local-dir (git-repo-local-dir repo)))
(if (uiop:probe-file* local-dir) (cond
;; Repo is present, need to fetch if the ref is not present or the ref ((uiop:probe-file* local-dir)
;; is a branch. ;; Repo is present, need to fetch if the ref is not present or the ref
(when (or (eql ref-type :branch) ;; is a branch.
(not (ref-present-p repo ref))) (when (and (or (eql ref-type :branch)
(with-retries (:max 10 :sleep 5) (not (ref-present-p repo ref)))
(fetch-repo! repo)) *fetch-repo-automatically*)
;; Make sure the ref is actually present, raising an error otherwise. (with-retries (:max 10 :sleep 5)
(unless (ref-present-p repo ref) (fetch-repo! repo))
(error "ref is not present, even after updating."))) ;; Make sure the ref is actually present, raising an error otherwise.
;; Repo is not present at all, need to clone it. (unless (ref-present-p repo ref)
(with-retries (:max 10 :sleep 5) (error "ref ~S is not present" ref))))
(clone-repo! repo) (*fetch-repo-automatically*
;; Make sure the ref is actually present, raising an error otherwise. ;; Repo is not present at all, need to clone it.
(unless (ref-present-p repo ref) (with-retries (:max 10 :sleep 5)
(error "ref is not present, even after updating."))))))) (clone-repo! repo)
;; Make sure the ref is actually present, raising an error otherwise.
(unless (ref-present-p repo ref)
(error "ref is not present, even after updating."))))
(t
;; Repo is not present and we were told to not fetch it. Error.
(error "Repo is not present at ~A" local-dir))))))
(defmethod repo-archive-stream ((repo git-repo) ref) (defmethod repo-archive-stream ((repo git-repo) ref)
(values (values
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment