Skip to content

Commit

Permalink
feat(core)!: run bump and upgrade asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Feb 22, 2024
1 parent 35855b2 commit 445ba4b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CLOC=cloc
all:
@echo "Cleaning options are: clean, clean_pcache, clean_all, prune, loaddefs."
@echo "Straight options are: pull, rebuild, check."
@echo "Extra options are: update, cloc, ci."
@echo "Extra options are: bump, cloc, ci."

clean:
rm -rf $(EMACS_DIR)/eln-cache $(EMACS_DIR)/local/eln-cache $(EMACS_DIR)/local/cache $(EMACS_DIR)/local/straight/build-*
Expand Down Expand Up @@ -38,11 +38,11 @@ rebuild:
check:
$(EMACS_BATCH) --eval='(straight-check-all)'

update:
MINEMACS_LOAD_ALL_MODULES=1 $(EMACS_BATCH) --eval='(minemacs-update-packages)'
bump:
MINEMACS_LOAD_ALL_MODULES=1 $(EMACS_BATCH) --eval='(minemacs--bump-packages)'

locked:
$(EMACS_BATCH) --eval='(minemacs-update-restore-locked nil)'
$(EMACS_BATCH) --eval='(minemacs-restore-locked-packages nil)'

cloc:
$(CLOC) --match-f='\.el$$' init.el early-init.el elisp/ modules/ core/ skel/
Expand Down
31 changes: 26 additions & 5 deletions core/me-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -608,17 +608,16 @@ Returns the load path of the package, useful for usage with `use-package''s
Call functions without asking when DONT-ASK-P is non-nil."
(interactive "P")
(dolist (fn minemacs-build-functions)
(message "MinEmacs: Running `%s'" fn)
(message "[MinEmacs]: Running `%s'" fn)
(if dont-ask-p
;; Do not ask before installing
(cl-letf (((symbol-function 'yes-or-no-p) #'always)
((symbol-function 'y-or-n-p) #'always))
(funcall-interactively fn))
(funcall-interactively fn))))

(defun minemacs-update-packages ()
"Update MinEmacs packages."
(interactive)
(defun minemacs--bump-packages ()
"Bump MinEmacs packages to the latest revisions."
;; Backup the current installed versions, this file can be restored if version
;; upgrade does break some packages.
(message "[MinEmacs]: Creating backups for the current versions of packages")
Expand Down Expand Up @@ -650,7 +649,14 @@ Call functions without asking when DONT-ASK-P is non-nil."
(message "[MinEmacs]: Running additional package-specific build functions")
(minemacs-run-build-functions 'dont-ask))

(defun minemacs-update-restore-locked (restore-from-backup)
(defun minemacs-bump-packages ()
"Update MinEmacs packages to the last revisions (can cause breakages)."
(interactive)
(let ((default-directory minemacs-root-dir)
(compilation-buffer-name-function (lambda (_) "" "*minemacs-bump-packages*")))
(compile "make bump")))

(defun minemacs-restore-locked-packages (restore-from-backup)
"Restore lockfile packages list. Takes into account the pinned ones.
When called with \\[universal-argument] or with RESTORE-FROM-BACKUP, it will
restore the lockfile from backups, not Git."
Expand Down Expand Up @@ -690,6 +696,21 @@ restore the lockfile from backups, not Git."
(message "[MinEmacs] Running additional package-specific build functions")
(minemacs-run-build-functions 'dont-ask)))

(define-obsolete-function-alias 'minemacs-update-packages 'minemacs-bump-packages "v5.0")
(define-obsolete-function-alias 'minemacs-update-restore-locked 'minemacs-restore-locked-packages "v5.0")

(defun minemacs-upgrade (pull-minemacs)
"Upgrade MinEmacs and its packages to the latest pinned versions (recommended).
When PULL-MINEMACS is non-nil, run a \"git pull\" in MinEmacs' directory.
This calls `minemacs-update-restore-locked' asynchronously."
(interactive "P")
(let ((default-directory minemacs-root-dir)
(compilation-buffer-name-function (lambda (_) "" "*minemacs-upgrade*"))
(cmd (format "sh -c '%smake locked'" (if pull-minemacs "git pull && " ""))))
(compile cmd)))

(defun +minemacs-root-dir-cleanup ()
"Cleanup MinEmacs' root directory."
(let ((default-directory minemacs-root-dir))
Expand Down

0 comments on commit 445ba4b

Please sign in to comment.