(defun cherry-pick-new-commits ()
"Pick or skip new commits in the upstream branch."
(interactive)
+ (message "Fetching from upstream...")
(call-process "git" nil nil nil
"-C" source-directory "fetch" cherry-upstream-remote)
+ (message "Checking for new commits...")
(let* ((merge-base (cherry-merge-base))
(new-commits
(seq-remove
(or (cherry-picked-p commit merge-base)
(cherry-skipped-p commit)))
(cherry-upstream-commits))))
- (if new-commits
- (dolist (commit new-commits)
- (with-current-buffer (get-buffer-create "*cherry*")
- (delete-region (point-min) (point-max))
- (fundamental-mode))
- (call-process "git" nil "*cherry*" t "-C" source-directory
- "format-patch" "-1" commit "--stdout")
- (pop-to-buffer "*cherry*")
- (diff-mode)
- (goto-char (point-min))
- (let ((choice (read-multiple-choice
- "Pick?"
- '((?p "pick")
- (?s "skip")
- (?q "quit")
- ;; (?a "amend")
- ))))
- (pcase (car choice)
- (?s
- (message "Skipping...")
- (shell-command (concat "echo " commit
- (read-string "Reason: " "")
- ">>" cherry-skip-list-file))
- (message "Skipped."))
- (?p
- (message "Picking...")
- (if (= 0 (call-process "git" nil nil nil
- "-C" source-directory
- "cherry-pick" "-x" commit))
- (message "Picked.")
- (user-error "Cherry picking failed")))
- (?q (bury-buffer "*cherry*")
- (user-error "Quit cherry picking")))))
- (message "No new commits."))))
+ (if (null new-commits)
+ (message "No new commits.")
+ (dolist (commit new-commits)
+ (with-current-buffer (get-buffer-create "*cherry*")
+ (delete-region (point-min) (point-max))
+ (fundamental-mode))
+ (call-process "git" nil "*cherry*" t "-C" source-directory
+ "format-patch" "-1" commit "--stdout")
+ (pop-to-buffer "*cherry*")
+ (diff-mode)
+ (goto-char (point-min))
+ (let ((choice (read-multiple-choice
+ "Pick?"
+ '((?p "pick")
+ (?s "skip")
+ (?q "quit")
+ ;; (?a "amend")
+ ))))
+ (pcase (car choice)
+ (?s
+ (message "Skipping...")
+ (shell-command (concat "echo " commit
+ (read-string "Reason: " "")
+ ">>" cherry-skip-list-file))
+ (message "Skipped."))
+ (?p
+ (message "Picking...")
+ (if (= 0 (call-process "git" nil nil nil
+ "-C" source-directory
+ "cherry-pick" "-x" commit))
+ (message "Picked.")
+ (user-error "Cherry picking failed")))
+ (?q (bury-buffer "*cherry*")
+ (user-error "Quit cherry picking")))))
+ (message "Done."))))
(provide 'cherry)
;;; cherry.el ends here