From 12a765c5099c4aab8165d1ee944b71f105e42fe1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 26 Mar 2024 21:33:00 -0400 Subject: [PATCH] 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: cff091982e41 --- lisp/cli/sync.el | 23 +++++++++++++---------- lisp/cli/upgrade.el | 3 ++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lisp/cli/sync.el b/lisp/cli/sync.el index f74a97923..54fbf0117 100644 --- a/lisp/cli/sync.el +++ b/lisp/cli/sync.el @@ -26,8 +26,8 @@ (noupdate? ("-U") "Don't update any packages") (purge? ("--gc") "Purge orphaned package repos & regraft them") (jobs ("-j" "--jobs" num) "How many threads to use for native compilation") - (rebuild? ("-b" "--rebuild") "Rebuild, compile, & symlink installed packages") - (auto? ("-B") "Rebuild packages, but only if necessary") + (rebuild? ("-b" "--rebuild") "Rebuild all installed packages, unconditionally") + (nobuild? ("-B") "Don't rebuild packages when hostname or Emacs version has changed") &context context) "Synchronize your config with Doom Emacs. @@ -52,8 +52,6 @@ OPTIONS: :benchmark t (when (doom-profiles-bootloadable-p) (call! '(profiles sync "--reload"))) - (when (doom-cli-context-suppress-prompts-p context) - (setq auto? t)) (when jobs (setq native-comp-async-jobs-number (truncate jobs))) (run-hooks 'doom-before-sync-hook) @@ -75,11 +73,14 @@ OPTIONS: (when (and old-host (not (equal old-host (system-name)))) (print! (warn "Your system has changed since last sync")) (setq to-rebuild t)) - (when (and to-rebuild (not auto?)) - (or (y-or-n-p - (format! " %s" "Your installed packages will need to be recompiled. Do so now?")) - (exit! 0)) - (setq rebuild? t))) + (when (and to-rebuild (not (doom-cli-context-suppress-prompts-p context))) + (if nobuild? + (print! (warn "Packages need to be recompiled, but -B has prevented it. Skipping...")) + (or (not (doom-cli-context-get context 'upgrading)) + (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?) (file-exists-p doom-env-file)) (call! '(env))) @@ -89,7 +90,9 @@ OPTIONS: (when (doom-profile-generate) (print! (item "Restart Emacs or use 'M-x doom/reload' for changes to take effect")) (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) (remove-hook 'kill-emacs-hook #'doom-sync--abort-warning-h))) diff --git a/lisp/cli/upgrade.el b/lisp/cli/upgrade.el index 9f44d6e93..d42017caa 100644 --- a/lisp/cli/upgrade.el +++ b/lisp/cli/upgrade.el @@ -32,7 +32,7 @@ following shell commands: doom clean doom sync -u" (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 (packages? ;; 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. ;; Major changes will still break, however (print! (item "Reloading Doom Emacs")) + (doom-cli-context-put context 'upgrading t) (exit! "doom" "upgrade" "-p" (if force? "--force") (if jobs (format "--jobs=%d" jobs))))