feat(cli): doom sync: change -B to suppress rebuilding

Prior to this, -B would suppress the prompt for package rebuilding if
your Emacs version or hostname changed. Now, it fully inhibits
rebuilding in either case.

Fix: #7760
Ref: cff091982e
This commit is contained in:
Henrik Lissner 2024-03-26 21:33:00 -04:00
parent d256b597f2
commit 12a765c509
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
2 changed files with 15 additions and 11 deletions

View file

@ -26,8 +26,8 @@
(noupdate? ("-U") "Don't update any packages") (noupdate? ("-U") "Don't update any packages")
(purge? ("--gc") "Purge orphaned package repos & regraft them") (purge? ("--gc") "Purge orphaned package repos & regraft them")
(jobs ("-j" "--jobs" num) "How many threads to use for native compilation") (jobs ("-j" "--jobs" num) "How many threads to use for native compilation")
(rebuild? ("-b" "--rebuild") "Rebuild, compile, & symlink installed packages") (rebuild? ("-b" "--rebuild") "Rebuild all installed packages, unconditionally")
(auto? ("-B") "Rebuild packages, but only if necessary") (nobuild? ("-B") "Don't rebuild packages when hostname or Emacs version has changed")
&context context) &context context)
"Synchronize your config with Doom Emacs. "Synchronize your config with Doom Emacs.
@ -52,8 +52,6 @@ OPTIONS:
:benchmark t :benchmark t
(when (doom-profiles-bootloadable-p) (when (doom-profiles-bootloadable-p)
(call! '(profiles sync "--reload"))) (call! '(profiles sync "--reload")))
(when (doom-cli-context-suppress-prompts-p context)
(setq auto? t))
(when jobs (when jobs
(setq native-comp-async-jobs-number (truncate jobs))) (setq native-comp-async-jobs-number (truncate jobs)))
(run-hooks 'doom-before-sync-hook) (run-hooks 'doom-before-sync-hook)
@ -75,11 +73,14 @@ OPTIONS:
(when (and old-host (not (equal old-host (system-name)))) (when (and old-host (not (equal old-host (system-name))))
(print! (warn "Your system has changed since last sync")) (print! (warn "Your system has changed since last sync"))
(setq to-rebuild t)) (setq to-rebuild t))
(when (and to-rebuild (not auto?)) (when (and to-rebuild (not (doom-cli-context-suppress-prompts-p context)))
(or (y-or-n-p (if nobuild?
(format! " %s" "Your installed packages will need to be recompiled. Do so now?")) (print! (warn "Packages need to be recompiled, but -B has prevented it. Skipping..."))
(exit! 0)) (or (not (doom-cli-context-get context 'upgrading))
(setq rebuild? t))) (y-or-n-p
(format! " %s" "Your installed packages will need to be recompiled. Do so now?"))
(exit! 0))
(setq rebuild? t))))
(when (and (not noenvvar?) (when (and (not noenvvar?)
(file-exists-p doom-env-file)) (file-exists-p doom-env-file))
(call! '(env))) (call! '(env)))
@ -89,7 +90,9 @@ OPTIONS:
(when (doom-profile-generate) (when (doom-profile-generate)
(print! (item "Restart Emacs or use 'M-x doom/reload' for changes to take effect")) (print! (item "Restart Emacs or use 'M-x doom/reload' for changes to take effect"))
(run-hooks 'doom-after-sync-hook)) (run-hooks 'doom-after-sync-hook))
(with-temp-file doom-cli-sync-info-file (prin1 (cons emacs-version (system-name)) (current-buffer))) (when (and (not rebuild?) (not nobuild?))
(with-temp-file doom-cli-sync-info-file
(prin1 (cons emacs-version (system-name)) (current-buffer))))
t) t)
(remove-hook 'kill-emacs-hook #'doom-sync--abort-warning-h))) (remove-hook 'kill-emacs-hook #'doom-sync--abort-warning-h)))

View file

@ -32,7 +32,7 @@ following shell commands:
doom clean doom clean
doom sync -u" doom sync -u"
(let* ((force? (doom-cli-context-suppress-prompts-p context)) (let* ((force? (doom-cli-context-suppress-prompts-p context))
(sync-cmd (append '("sync" "-u" "-B") (if jobs `("-j" ,num))))) (sync-cmd (append '("sync" "-u") (if jobs `("-j" ,num)))))
(cond (cond
(packages? (packages?
;; HACK It's messy to use straight to upgrade straight, due to the ;; HACK It's messy to use straight to upgrade straight, due to the
@ -53,6 +53,7 @@ following shell commands:
;; Reload Doom's CLI & libraries, in case there were any upstream changes. ;; Reload Doom's CLI & libraries, in case there were any upstream changes.
;; Major changes will still break, however ;; Major changes will still break, however
(print! (item "Reloading Doom Emacs")) (print! (item "Reloading Doom Emacs"))
(doom-cli-context-put context 'upgrading t)
(exit! "doom" "upgrade" "-p" (exit! "doom" "upgrade" "-p"
(if force? "--force") (if force? "--force")
(if jobs (format "--jobs=%d" jobs)))) (if jobs (format "--jobs=%d" jobs))))