Henrik Lissner 2021-04-29 15:07:13 -04:00
parent 259cf83ef1
commit f60f576048
4 changed files with 84 additions and 53 deletions

View file

@ -31,7 +31,7 @@ Warning: freezes indefinitely on any stdin prompt."
(set-process-filter
process (lambda (_process output)
(princ output (current-buffer))
(princ output)))
(princ (doom--format output))))
(set-process-sentinel
process (lambda (process _event)
(when (memq (process-status process) '(exit stop))

View file

@ -10,10 +10,18 @@
(stringp data)
(string-match-p (regexp-quote straight-process-buffer)
data)
(straight--process-get-output))))
(with-current-buffer (straight--process-buffer)
(split-string (buffer-string) "\n" t)))))
(cond (straight-error
(print! (error "The package manager threw an error"))
(print-group! (print! "%s" (string-trim straight-error))))
(print! (error "Last 25 lines of straight's error log:"))
(print-group!
(print!
"%s" (string-join
(seq-subseq straight-error
(max 0 (- (length straight-error) 25))
(length straight-error))
"\n"))))
((print! (error "There was an unexpected error"))
(print-group!
(print! "%s %s" (bold "Message:") (get type 'error-message))
@ -37,7 +45,7 @@
(print-level nil)
(print-circle nil))
(when straight-error
(print (string-trim straight-error)))
(print (string-join straight-error "\n")))
(mapc #'print (cons (list type data) backtrace)))
(print! (warn "Extended backtrace logged to %s")
(relpath doom-cli-log-error-file)))))))

View file

@ -63,15 +63,34 @@ list remains lean."
(if full commit (substring commit 0 7)))
(defun doom--commit-log-between (start-ref end-ref)
(when-let*
((status (straight--call
"git" "log" "--oneline" "--no-merges"
"-n" "26" end-ref (concat "^" (regexp-quote start-ref))))
(output (string-trim-right (straight--process-get-output)))
(lines (split-string output "\n")))
(if (> (length lines) 25)
(concat (string-join (butlast lines 1) "\n") "\n[...]")
output)))
(straight--process-with-result
(straight--process-run
"git" "log" "--oneline" "--no-merges"
"-n" "26" end-ref (concat "^" (regexp-quote start-ref)))
(if success
(let* ((output (string-trim-right stdout))
(lines (split-string output "\n")))
(if (> (length lines) 25)
(concat (string-join (butlast lines 1) "\n") "\n[...]")
output))
(format "ERROR: Couldn't collect commit list because: %s" stderr))))
(defmacro doom--straight-with (form &rest body)
(declare (indent 1))
`(let-alist
(let* ((buffer (straight--process-buffer))
(start (with-current-buffer buffer (point-max)))
(retval ,form)
(output (with-current-buffer buffer (buffer-substring start (point-max)))))
(save-match-data
(list (cons 'it retval)
(cons 'stdout (substring-no-properties output))
(cons 'success (if (string-match "\n+\\[Return code: \\([0-9-]+\\)\\]\n+" output)
(string-to-number (match-string 1 output))))
(cons 'output (string-trim output
"^\\(\\$ [^\n]+\n\\)*\n+"
"\n+\\[Return code: [0-9-]+\\]\n+")))))
,@body))
(defun doom--barf-if-incomplete-packages ()
(let ((straight-safe-mode t))
@ -101,24 +120,25 @@ list remains lean."
(print! (start "Updating recipe repos..."))
(print-group!
(doom--with-package-recipes
(delq
nil (mapcar (doom-rpartial #'gethash straight--repo-cache)
(mapcar #'symbol-name straight-recipe-repositories)))
(recipe package type local-repo)
(let ((esc (unless doom-debug-p "\033[1A"))
(ref (straight-vc-get-commit type local-repo))
newref output)
(print! (start "\033[KUpdating recipes for %s...%s") package esc)
(when (straight-vc-fetch-from-remote recipe)
(setq output (straight--process-get-output))
(straight-merge-package package)
(unless (equal ref (setq newref (straight-vc-get-commit type local-repo)))
(print! (success "\033[K%s updated (%s -> %s)")
package
(doom--abbrev-commit ref)
(doom--abbrev-commit newref))
(unless (string-empty-p output)
(print-group! (print! (info "%s" output)))))))))
(delq
nil (mapcar (doom-rpartial #'gethash straight--repo-cache)
(mapcar #'symbol-name straight-recipe-repositories)))
(recipe package type local-repo)
(let ((esc (unless doom-debug-p "\033[1A"))
(ref (straight-vc-get-commit type local-repo))
newref output)
(print! (start "\033[KUpdating recipes for %s...%s") package esc)
(doom--straight-with (straight-vc-fetch-from-remote recipe)
(when .it
(setq output .output)
(straight-merge-package package)
(unless (equal ref (setq newref (straight-vc-get-commit type local-repo)))
(print! (success "\033[K%s updated (%s -> %s)")
package
(doom--abbrev-commit ref)
(doom--abbrev-commit newref))
(unless (string-empty-p output)
(print-group! (print! (info "%s" output))))))))))
(setq straight--recipe-lookup-cache (make-hash-table :test #'eq)
doom--cli-updated-recipes t)))
@ -384,12 +404,13 @@ declaration) or dependency thereof that hasn't already been."
(or (cond
((not (stringp target-ref))
(print! (start "\033[K(%d/%d) Fetching %s...%s") i total package esc)
(when (straight-vc-fetch-from-remote recipe)
(setq output (straight--process-get-output))
(straight-merge-package package)
(setq target-ref (straight-vc-get-commit type local-repo))
(or (not (doom--same-commit-p target-ref ref))
(cl-return))))
(doom--straight-with (straight-vc-fetch-from-remote recipe)
(when .it
(setq output .output)
(straight-merge-package package)
(setq target-ref (straight-vc-get-commit type local-repo))
(or (not (doom--same-commit-p target-ref ref))
(cl-return)))))
((doom--same-commit-p target-ref ref)
(print! (info "\033[K(%d/%d) %s is up-to-date...%s") i total package esc)
@ -474,16 +495,18 @@ declaration) or dependency thereof that hasn't already been."
(print! (warn "\033[KSkipping repos/%s because it is local" repo))
(cl-return))
(let ((before-size (doom-directory-size default-directory)))
(straight--call "git" "reset" "--hard")
(straight--call "git" "clean" "-ffd")
(if (not (car (straight--call "git" "replace" "--graft" "HEAD")))
(doom-call-process "git" "reset" "--hard")
(doom-call-process "git" "clean" "-ffd")
(if (not (zerop (car (doom-call-process "git" "replace" "--graft" "HEAD"))))
(print! (info "\033[Krepos/%s is already compact\033[1A" repo))
(straight--call "git" "reflog" "expire" "--expire=all" "--all")
(straight--call "git" "gc" "--prune=now")
(print! (success "\033[KRegrafted repos/%s (from %0.1fKB to %0.1fKB)")
repo before-size (doom-directory-size default-directory))
(print-group! (print! "%s" (straight--process-get-output))))
t)))
(doom-call-process "git" "reflog" "expire" "--expire=all" "--all")
(doom-call-process "git" "gc" "--prune=now")
(let ((after-size (doom-directory-size default-directory)))
(if (equal after-size before-size)
(print! (success "\033[Krepos/%s cannot be compacted further" repo))
(print! (success "\033[KRegrafted repos/%s (from %0.1fKB to %0.1fKB)")
repo before-size after-size)))))
t))
(defun doom--cli-packages-regraft-repos (repos)
(if (not repos)

View file

@ -17,7 +17,7 @@
:branch ,straight-repository-branch
:local-repo "straight.el"
:files ("straight*.el"))
:pin "0f9b828d8a41cf3d312678e82573066aebf2ab6e")
:pin "253d7db6c1165741208219e7b3a29beb12dcd731")
;; core-modules.el
(package! use-package
@ -25,7 +25,7 @@
:pin "a7422fb8ab1baee19adb2717b5b47b9c3812a84c")
;; core-ui.el
(package! all-the-icons :pin "a8c84176af7f3b97019423ebf3e02f983f4ebdf9")
(package! all-the-icons :pin "7a1225826798622d5dbe416b1d5e0a6fba8c19d7")
(package! hide-mode-line :pin "88888825b5b27b300683e662fa3be88d954b1cea")
(package! highlight-numbers :pin "8b4744c7f46c72b1d3d599d4fb75ef8183dee307")
(package! rainbow-delimiters :pin "f43d48a24602be3ec899345a3326ed0247b960c6")
@ -33,12 +33,12 @@
;; core-editor.el
(package! better-jumper :pin "411ecdf6e7a3e1b4ced7605070d2309e5fc46556")
(package! dtrt-indent :pin "37529fc7a98564164c87103e5107a6dca32b0e44")
(package! dtrt-indent :pin "9714f2c5f1c9b7c21e732df8c15a870a88caba84")
(package! helpful :pin "7e4b1f0d5572a4e2b8ee7a9b084ef863d0315a73")
(package! pcre2el :pin "0b5b2a2c173aab3fd14aac6cf5e90ad3bf58fa7d")
(package! smartparens :pin "63695c64233d215a92bf08e762f643cdb595bdd9")
(package! smartparens :pin "25f4d6d1b732f4deabf922059d22a0a7dc04bd0a")
;; DEPRECATED Built into Emacs 27+; remove when we drop 26 support
(package! so-long :built-in 'prefer :pin "a5d445de4829b2327bd51dad2fb04291c7a0ec5f")
(package! so-long :built-in 'prefer :pin "1da43ed63b5f9a8188eb8107bbad842d10831537")
(package! ws-butler
;; Use my fork of ws-butler, which has a few choice improvements and
;; optimizations (the original has been abandoned).
@ -46,8 +46,8 @@
:pin "2bb49d3ee7d2cba133bc7e9cdac416cd1c5e4fe0")
;; core-projects.el
(package! projectile :pin "1528ed4f082e7aaca19f22394eb4bed879645b7c")
(package! projectile :pin "513228f473910128efcad13f46dfc22a74976675")
;; core-keybinds.el
(package! general :pin "a0b17d207badf462311b2eef7c065b884462cb7c")
(package! which-key :pin "c632dbf27a77c1c73ce559041b3a78ec5f78b187")
(package! which-key :pin "5fb30301cb3b4fca5a0e1ce8ec1ef59290b79199")