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 @@
#:clpm/context
#:clpm/install
#:clpm/log
#:clpm/repos
#:clpm/resolve
#:clpm/source)
(:export #:bundle-install
......@@ -51,7 +52,8 @@
(defun bundle-install (clpmfile-designator &key localp (validate (constantly t)))
"Given a clpmfile instance, install all releases from its lock file, creating
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 nil)
(changedp nil))
......@@ -75,7 +77,8 @@ the lock file if necessary."
update-projects (validate (constantly t))
update-systems
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 nil)
(changedp nil))
......
......@@ -6,7 +6,8 @@
(uiop:define-package #:clpm/repos/defs
(:use #:cl)
(:export #:ensure-ref-present-locally!
(:export #:*fetch-repo-automatically*
#:ensure-ref-present-locally!
#:ref-present-p
#:repo-archive-stream
#:repo-lib-base-pathname
......@@ -15,6 +16,8 @@
(in-package #:clpm/repos/defs)
(defvar *fetch-repo-automatically* t)
(defgeneric ensure-ref-present-locally! (repo ref))
(defgeneric ref-present-p (repo ref))
......
......@@ -218,22 +218,28 @@ ref is present locally, fetching or cloning the repo as necessary."
(destructuring-bind (ref-type ref-name) ref
(declare (ignore ref-name))
(let ((local-dir (git-repo-local-dir repo)))
(if (uiop:probe-file* local-dir)
;; Repo is present, need to fetch if the ref is not present or the ref
;; is a branch.
(when (or (eql ref-type :branch)
(not (ref-present-p repo ref)))
(with-retries (:max 10 :sleep 5)
(fetch-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.")))
;; Repo is not present at all, need to clone it.
(with-retries (:max 10 :sleep 5)
(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.")))))))
(cond
((uiop:probe-file* local-dir)
;; Repo is present, need to fetch if the ref is not present or the ref
;; is a branch.
(when (and (or (eql ref-type :branch)
(not (ref-present-p repo ref)))
*fetch-repo-automatically*)
(with-retries (:max 10 :sleep 5)
(fetch-repo! repo))
;; Make sure the ref is actually present, raising an error otherwise.
(unless (ref-present-p repo ref)
(error "ref ~S is not present" ref))))
(*fetch-repo-automatically*
;; Repo is not present at all, need to clone it.
(with-retries (:max 10 :sleep 5)
(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)
(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