Skip to content

Commit

Permalink
tweak(core): better error handling in minemacs-update-restore-locked
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Oct 7, 2023
1 parent b0276fa commit ffe08fa
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions elisp/+minemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -474,27 +474,28 @@ Works like `shell-command-to-string' with two differences:
(message "[MinEmacs]: Rebuilding packages")
(straight-rebuild-all)

;; Runn package-specific build functions (ex: `pdf-tools-install')
;; Run package-specific build functions (ex: `pdf-tools-install')
(message "[MinEmacs]: Running additional package-specific build functions")
(minemacs-run-build-functions 'dont-ask))

(defun minemacs-update-restore-locked ()
"Restore lockfile packages list. Takes into account the pinned ones."
(interactive)
(let* ((lockfile (concat straight-base-dir "straight/versions/default.el"))
(default-directory (vc-git-root lockfile)))
(message "[MinEmacs]: Reverting file \"%s\" to the original" lockfile)
(unless (zerop (vc-git-revert lockfile))
(+error! "An error occured when trying to revert \"%s\"" lockfile)))

(message "[MinEmacs]: Restoring packages to the reverted lockfile versions")
(straight-x-thaw-pinned-versions)
(message "[MinEmacs]: Rebuilding packages")
(straight-rebuild-all)

;; Runn package-specific build functions (ex: `pdf-tools-install')
(message "[MinEmacs]: Running additional package-specific build functions")
(minemacs-run-build-functions 'dont-ask))
(if (not (let* ((lockfile (concat straight-base-dir "straight/versions/default.el"))
(default-directory (vc-git-root lockfile)))
(message "[MinEmacs] Reverting file \"%s\" to the original" lockfile)
(zerop (vc-git-revert lockfile))))
;; Signal an error when the `vc-git-revert' returns non-zero
(user-error "[MinEmacs] An error occured when trying to revert \"%s\"" lockfile)
;; Restore packages to the versions pinned in lockfile
(message "[MinEmacs] Restoring packages to the reverted lockfile versions")
(straight-x-thaw-pinned-versions)
;; Rebuild the packages
(message "[MinEmacs] Rebuilding packages")
(straight-rebuild-all)
;; Run package-specific build functions (ex: `pdf-tools-install')
(message "[MinEmacs] Running additional package-specific build functions")
(minemacs-run-build-functions 'dont-ask)))


;;; +minemacs.el ends here

0 comments on commit ffe08fa

Please sign in to comment.