fix(cli): failure to repin packages installed from snapshots

When a pinned package is repinned, the package manager attempts to  `git
checkout` the new pin, which won't work if the package isn't a git
repo (see 8cdddd87).

Amend: 8cdddd87d9
This commit is contained in:
Henrik Lissner
2025-09-01 21:19:03 +02:00
parent c664e1edef
commit a91f93a33a

View File

@@ -1112,10 +1112,14 @@ Must be run from a magit diff buffer."
(print! (start "\r(%d/%d) Fetching %s...%s") i total package esc) (print! (start "\r(%d/%d) Fetching %s...%s") i total package esc)
(and (straight-vc-fetch-from-remote recipe) (and (straight-vc-fetch-from-remote recipe)
(straight-vc-commit-present-p recipe target-ref))) (straight-vc-commit-present-p recipe target-ref)))
(straight-vc-check-out-commit recipe target-ref) (if (file-exists-p ".straight-commit")
(or (not (eq type 'git)) (progn
(setq output (doom-packages--commit-log-between ref target-ref) (delete-directory default-directory t)
commits (length (split-string output "\n" t)))) (straight-vc-git-clone recipe target-ref))
(straight-vc-check-out-commit recipe target-ref)
(or (not (eq type 'git))
(setq output (doom-packages--commit-log-between ref target-ref)
commits (length (split-string output "\n" t)))))
(doom-packages--same-commit-p target-ref (straight-vc-get-commit type local-repo))) (doom-packages--same-commit-p target-ref (straight-vc-get-commit type local-repo)))
((print! (start "\r(%d/%d) Re-cloning %s...") i total local-repo esc) ((print! (start "\r(%d/%d) Re-cloning %s...") i total local-repo esc)
@@ -1163,7 +1167,7 @@ Must be run from a magit diff buffer."
(if (> n 0) (if (> n 0)
(format " (w/ %d dependents)" n) (format " (w/ %d dependents)" n)
""))) "")))
(unless (string-empty-p output) (when (and (stringp output) (not (string-empty-p output)))
(let ((lines (split-string output "\n"))) (let ((lines (split-string output "\n")))
(setq output (setq output
(if (> (length lines) 20) (if (> (length lines) 20)