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:
Henrik Lissner 2018-05-28 12:19:58 +02:00
parent 5b31fd9505
commit c8b21e8cf8
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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)))