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 (set-process-filter
process (lambda (_process output) process (lambda (_process output)
(princ output (current-buffer)) (princ output (current-buffer))
(princ output))) (princ (doom--format output))))
(set-process-sentinel (set-process-sentinel
process (lambda (process _event) process (lambda (process _event)
(when (memq (process-status process) '(exit stop)) (when (memq (process-status process) '(exit stop))

View file

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

View file

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

View file

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