Clean up _upgrade rmeote after 'doom upgrade'

This commit is contained in:
Henrik Lissner 2019-07-29 03:47:56 +02:00
parent ba07fe575e
commit 2b81233353
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -65,43 +65,47 @@ following shell commands:
(doom--sh "git" "clean" "-ffd"))) (doom--sh "git" "clean" "-ffd")))
(doom--sh "git" "remote" "remove" doom-repo-remote) (doom--sh "git" "remote" "remove" doom-repo-remote)
(or (car (doom--sh "git" "remote" "add" doom-repo-remote doom-repo-url)) (unwind-protect
(error "Failed to add %s to remotes" doom-repo-remote)) (progn
(or (car (doom--sh "git" "fetch" "--tags" doom-repo-remote branch)) (or (car (doom--sh "git" "remote" "add" doom-repo-remote doom-repo-url))
(error "Failed to fetch from upstream")) (error "Failed to add %s to remotes" doom-repo-remote))
(or (car (doom--sh "git" "fetch" "--tags" doom-repo-remote branch))
(error "Failed to fetch from upstream"))
(let ((this-rev (vc-git--rev-parse "HEAD")) (let ((this-rev (vc-git--rev-parse "HEAD"))
(new-rev (vc-git--rev-parse target-remote))) (new-rev (vc-git--rev-parse target-remote)))
(cond (cond
((and (null this-rev) ((and (null this-rev)
(null new-rev)) (null new-rev))
(error "Failed to get revisions for %s" target-remote)) (error "Failed to get revisions for %s" target-remote))
((equal this-rev new-rev) ((equal this-rev new-rev)
(print! (success "Doom is already up-to-date!"))) (print! (success "Doom is already up-to-date!")))
((print! (info "Updates are available!\n\n Old revision: %s (%s)\n\n New revision: %s (%s)\n\n" ((print! (info "Updates are available!\n\n Old revision: %s (%s)\n\n New revision: %s (%s)\n\n"
(substring this-rev 0 10) (substring this-rev 0 10)
(cdr (doom--sh "git" "log" "-1" "--format=%cr" "HEAD")) (cdr (doom--sh "git" "log" "-1" "--format=%cr" "HEAD"))
(substring new-rev 0 10) (substring new-rev 0 10)
(cdr (doom--sh "git" "log" "-1" "--format=%cr" target-remote)))) (cdr (doom--sh "git" "log" "-1" "--format=%cr" target-remote))))
(when (y-or-n-p "View the comparison diff in your browser?") (when (y-or-n-p "View the comparison diff in your browser?")
(print! (info "Opened github in your browser.")) (print! (info "Opened github in your browser."))
(browse-url (format "https://github.com/hlissner/doom-emacs/compare/%s...%s" (browse-url (format "https://github.com/hlissner/doom-emacs/compare/%s...%s"
this-rev this-rev
new-rev))) new-rev)))
(or (y-or-n-p "Proceed with upgrade?") (or (y-or-n-p "Proceed with upgrade?")
(user-error "Aborted")) (user-error "Aborted"))
(print! (start "Upgrading Doom Emacs...")) (print! (start "Upgrading Doom Emacs..."))
(print-group! (print-group!
(doom-clean-byte-compiled-files) (doom-clean-byte-compiled-files)
(unless (and (car (doom--sh "git" "reset" "--hard" target-remote)) (unless (and (car (doom--sh "git" "reset" "--hard" target-remote))
(equal (vc-git--rev-parse "HEAD") new-rev)) (equal (vc-git--rev-parse "HEAD") new-rev))
(error "Failed to check out %s" (substring new-rev 0 10))) (error "Failed to check out %s" (substring new-rev 0 10)))
(doom-delete-autoloads-file doom-autoload-file) (doom-delete-autoloads-file doom-autoload-file)
(doom-cli-refresh) (doom-cli-refresh)
(when (doom-packages-update doom-auto-accept) (when (doom-packages-update doom-auto-accept)
(doom-reload-package-autoloads 'force-p)) (doom-reload-package-autoloads 'force-p))
(print! (success "Done! Restart Emacs for changes to take effect."))))))))) (print! (success "Done! Restart Emacs for changes to take effect.")))))))
(ignore-errors
(doom--sh "git" "remote" "remove" doom-repo-remote))))))