Make 'doom update' Skip local packages

i.e. packages with a user-specified :local-repo
This commit is contained in:
Henrik Lissner 2019-12-14 20:50:16 -05:00
parent 7b709eed34
commit 8dd647b9bd
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -136,7 +136,9 @@ declaration) or dependency thereof that hasn't already been."
(defun doom-cli-packages-update () (defun doom-cli-packages-update ()
"Updates packages." "Updates packages."
(print! (start "Updating packages (this may take a while)...")) (print! (start "Updating packages (this may take a while)..."))
(let ((straight--packages-to-rebuild (make-hash-table :test #'equal)) ;; TODO Refactor me
(let ((straight--repos-dir (straight--repos-dir))
(straight--packages-to-rebuild (make-hash-table :test #'equal))
(total (hash-table-count straight--repo-cache)) (total (hash-table-count straight--repo-cache))
(i 1) (i 1)
errors) errors)
@ -144,29 +146,32 @@ declaration) or dependency thereof that hasn't already been."
(dolist (recipe (hash-table-values straight--repo-cache)) (dolist (recipe (hash-table-values straight--repo-cache))
(straight--with-plist recipe (package type local-repo) (straight--with-plist recipe (package type local-repo)
(condition-case-unless-debug e (condition-case-unless-debug e
(let* ((default-directory (straight--repos-dir local-repo)) (let ((default-directory (straight--repos-dir local-repo)))
(commit (straight-vc-get-commit type local-repo))) (if (not (file-in-directory-p default-directory straight--repos-dir))
(if (not (straight-vc-fetch-from-remote recipe)) (print! (warn "[%d/%d] Skipping %s because it is local")
(print! (warn "\033[K(%d/%d) Failed to fetch %s" i total package)) i total package)
(let ((output (straight--process-get-output))) (let ((commit (straight-vc-get-commit type local-repo)))
(straight-merge-package package) (if (not (straight-vc-fetch-from-remote recipe))
(let ((newcommit (straight-vc-get-commit type local-repo))) (print! (warn "\033[K(%d/%d) Failed to fetch %s" i total package))
(if (string= commit newcommit) (let ((output (straight--process-get-output)))
(print! (start "\033[K(%d/%d) %s is up-to-date\033[1A") i total package) (straight-merge-package package)
(ignore-errors (let ((newcommit (straight-vc-get-commit type local-repo)))
(delete-directory (straight--build-dir package) 'recursive)) (if (string= commit newcommit)
(puthash package t straight--packages-to-rebuild) (print! (start "\033[K(%d/%d) %s is up-to-date\033[1A") i total package)
(print! (info "\033[K(%d/%d) Updating %s...") i total package) (ignore-errors
(unless (string-empty-p output) (delete-directory (straight--build-dir package) 'recursive))
(print-group! (puthash package t straight--packages-to-rebuild)
(print! (info "%s") output) (print! (info "\033[K(%d/%d) Updating %s...") i total package)
(when (eq type 'git) (unless (string-empty-p output)
(straight--call "git" "log" "--oneline" newcommit (concat "^" commit)) (print-group!
(print-group! (print! (info "%s") output)
(print! "%s" (straight--process-get-output)))))) (when (eq type 'git)
(print! (success "(%d/%d) %s updated (%s -> %s)") i total package (straight--call "git" "log" "--oneline" newcommit (concat "^" commit))
(substring commit 0 7) (print-group!
(substring newcommit 0 7)))))) (print! "%s" (straight--process-get-output))))))
(print! (success "(%d/%d) %s updated (%s -> %s)") i total package
(substring commit 0 7)
(substring newcommit 0 7))))))))
(cl-incf i)) (cl-incf i))
(user-error (user-error
(signal 'user-error (error-message-string e))) (signal 'user-error (error-message-string e)))