I'm thinking about automating my following git workflow in emacs:
- checkout to a new branch
- remove some pattern in the last commit message
- commit (amend) it
- push it to upstream
How could I automate 4 steps in emacs?
And I've tried to combine step 2 and step 3 into one key in magit by:
(defun magit-commit-append-new-msg ()
(interactive)
(let* ((git-dir (magit-toplevel))
;; get last commit msg
;; TODO handle remote dir
(msg (shell-command-to-string (format "git -C \"%s\" log -1 --format=\"%%B\"" git-dir)))
;; remove changeid and jira line in msg
(msg-new (concat msg "[MYTEST]")))
(magit-git-command-topdir (format "git -C \"%s\" commit --amend -m \"%s\"" git-dir msg-new))))
(magit-define-popup-action 'magit-commit-popup
?i
"Commit with new msg"
'magit-commit-append-new-msg)
But I've not found a way do all 4 steps yet.
new-feature
and want your modified commit to be pushed toorigin/new-feature
?