cli/upgrade: fix dirty worktree detection

This commit is contained in:
Henrik Lissner 2019-12-13 14:53:52 -05:00
parent 8224f14d92
commit 7e0c093bcf
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -36,7 +36,7 @@ following shell commands:
(cl-destructuring-bind (success . stdout)
(doom-call-process "git" "status" "--porcelain" "-uno")
(if (= 0 success)
(string-match-p "[^ \t\n]" (buffer-string))
(split-string stdout "\n" t)
(error "Failed to check working tree in %s" dir))))
@ -55,11 +55,12 @@ following shell commands:
"Couldn't detect what branch you're on. Is Doom detached?")))
;; We assume that a dirty .emacs.d is intentional and abort
(when (doom--working-tree-dirty-p default-directory)
(when-let (dirty (doom--working-tree-dirty-p default-directory))
(if (not force-p)
(user-error! "%s\n\n%s"
(user-error! "%s\n\n%s\n\n %s"
(format "Refusing to upgrade because %S has been modified." (path doom-emacs-dir))
"Either stash/undo your changes or run 'doom upgrade -f' to discard local changes.")
"Either stash/undo your changes or run 'doom upgrade -f' to discard local changes."
(string-join dirty "\n"))
(print! (info "You have local modifications in Doom's source. Discarding them..."))
(doom-call-process "git" "reset" "--hard" (format "origin/%s" branch))
(doom-call-process "git" "clean" "-ffd")))