Fix #3228: 'Failed to fetch from upstream' on doom upgrade

Due to git name-rev returning fully qualified refs in some cases.
This commit is contained in:
Henrik Lissner 2020-05-29 17:52:01 -04:00
parent 200fd52b61
commit aec94f5bb2
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -52,10 +52,13 @@ following shell commands:
process-file-side-effects) process-file-side-effects)
(print! (start "Preparing to upgrade Doom Emacs and its packages...")) (print! (start "Preparing to upgrade Doom Emacs and its packages..."))
(let* ((branch (let* (;; git name-rev may return BRANCH~X for detached HEADs and fully
(string-trim-right ;; qualified refs in some other cases, so an effort to strip out all
(cdr (doom-call-process "git" "name-rev" "--name-only" "HEAD")) ;; but the branch name is necessary. git symbolic-ref (or
"~[0-9]$")) ;; `vc-git--symbolic-ref') won't work; it can't deal with submodules.
(branch (replace-regexp-in-string
"^\\(?:[^/]+/[^/]+/\\)?\\(.+\\)\\(?:~[0-9]+\\)?$" "\\1"
(cdr (doom-call-process "git" "name-rev" "--name-only" "HEAD"))))
(target-remote (format "%s/%s" doom-repo-remote branch))) (target-remote (format "%s/%s" doom-repo-remote branch)))
(unless branch (unless branch
(error! (if (file-exists-p! ".git" doom-emacs-dir) (error! (if (file-exists-p! ".git" doom-emacs-dir)