]> git.eshelyaron.com Git - emacs.git/commitdiff
; * admin/cherry.el (cherry-pick-new-commits): Improve.
authorEshel Yaron <me@eshelyaron.com>
Fri, 22 Dec 2023 18:14:40 +0000 (19:14 +0100)
committerEshel Yaron <me@eshelyaron.com>
Fri, 22 Dec 2023 18:16:50 +0000 (19:16 +0100)
admin/cherry.el

index ffcdcd70ada74127092aa6d7f6e772e2f173d91a..2911defeb84106df12d02dc62656da9d16462165 100644 (file)
 (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