Fix doom//upgrade dirty-tree detection
doom//upgrade refused to upgrade Doom because of unexpected behavior with vc-state, which unhelpfully returns 'unregistered for unmodified files. Instead, I manually test for output from git status --porcelain.
This commit is contained in:
parent
5b31fd9505
commit
c8b21e8cf8
1 changed files with 10 additions and 3 deletions
|
@ -208,12 +208,19 @@ recompile. Run this whenever you:
|
|||
;; Quality of Life Commands
|
||||
;;
|
||||
|
||||
;; FIXME Detect & enforce remote
|
||||
(defvar doom-repo-url "https://github.com/hlissner/doom-emacs"
|
||||
"TODO")
|
||||
(defvar doom-repo-remote "upgrade"
|
||||
(defvar doom-repo-remote "_upgrade"
|
||||
"TODO")
|
||||
|
||||
(defun doom--working-tree-dirty-p (dir)
|
||||
(with-temp-buffer
|
||||
(let ((default-directory dir))
|
||||
(if (zerop (process-file "git" nil (current-buffer) nil
|
||||
"status" "--porcelain"))
|
||||
(string-match-p "[^ \t\n]" (buffer-string))
|
||||
(error "Failed to check working tree in %s" dir)))))
|
||||
|
||||
(defun doom//upgrade ()
|
||||
"Upgrade Doom to the latest version."
|
||||
(interactive)
|
||||
|
@ -227,7 +234,7 @@ recompile. Run this whenever you:
|
|||
(unless branch
|
||||
(error "Couldn't detect what branch you're using. Is %s a repo?"
|
||||
(abbreviate-file-name doom-emacs-dir)))
|
||||
(unless (eq (vc-state doom-emacs-dir 'Git) 'up-to-date)
|
||||
(when (doom--working-tree-dirty-p doom-emacs-dir)
|
||||
(user-error "Refusing to upgrade because Doom has been modified. Stash or undo your changes"))
|
||||
(with-temp-buffer
|
||||
(let ((buf (current-buffer)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue