From 74f18ee9eb9e2b221d5a2dbaca05f95fa035d4d9 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 2 Jan 2024 12:02:02 +0100 Subject: [PATCH] ; (cherry-pick-new-commits): Improve error handling. --- admin/cherry.el | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/admin/cherry.el b/admin/cherry.el index c6dfb75a85b..d0ee48d7237 100644 --- a/admin/cherry.el +++ b/admin/cherry.el @@ -70,8 +70,8 @@ "Pick or skip new commits in the upstream branch." (interactive) (message "Ensuring working directory is clean...") - (or (eq 0 (cherry--call-git "diff-index" "--quiet" "HEAD" "--")) - (user-error "Working directory is dirty, cannot start cherry picking")) + (unless (= 0 (cherry--call-git "diff-index" "--quiet" "HEAD" "--")) + (user-error "Working directory is dirty, cannot start cherry picking")) (message "Fetching from upstream...") (cherry--call-git "fetch" cherry-upstream-remote) (message "Checking for new commits...") @@ -107,19 +107,24 @@ (pcase (car choice) (?s (message "Skipping...") - (shell-command (concat "echo " commit - (read-string "Reason: " "") - ">>" cherry-skip-list-file)) - (cherry--call-git "commit" "-m" - (concat "; Skip commit " commit) - (file-relative-name - cherry-skip-list-file source-directory)) + (unless (= 0 (shell-command + (concat "echo " commit + (shell-quote-argument + (read-string "Reason: " "")) + ">>" cherry-skip-list-file))) + (user-error "Failed to write commit to skip list")) + (unless (= 0 (cherry--call-git + "commit" "-m" + (concat "; Skip commit " commit) + (file-relative-name + cherry-skip-list-file source-directory))) + (user-error "Failed to commit updated skip list")) (message "Added to skip list and committed.")) (?p (message "Picking...") - (if (= 0 (cherry--call-git "cherry-pick" "-x" commit)) - (message "Picked.") - (user-error "Cherry picking failed"))) + (unless (= 0 (cherry--call-git "cherry-pick" "-x" commit)) + (user-error "Cherry picking failed")) + (message "Picked.")) (?q (bury-buffer "*cherry*") (user-error "Quit cherry picking")))))) (message "Done.")))) -- 2.39.5