Specially when editing my init.org file, I usually want to push every single change to origin. So I want to write a function to do this, I am almost there but still need some help.
(defun cesco/automatic-push ()
(magit-stage-modified)
(magit-commit (concat "-m \"" COMMIT MESSAGE "\"" ))
(magit-push MAGIT-CURRENT-BRANCH)
)
I want the commit message to be the current day/time and push the current branch to origin.
Update
I can successfully commit, but magit-push is running too fast so there is nothing commited yet. How can I make it wait for the commit to be done before attempting to push?
(defun cesco/push ()
(interactive)
(magit-stage-modified)
(magit-commit (concat "-m \"" (format-time-string "%Y-%m-%dT%H:%M:%S") "\""))
(magit-push)
)
Update 2
Code
(defun cesco/automatic-push ()
(interactive)
(magit-run-git "commit" "--all"
(format-time-string "--message=%F %R"))
(let ((current-branch (magit-get-current-branch)))
(message "PUSHING!!!!")
(magit-git-push current-branch
(concat "origin/" current-branch)
(list "--dry-run")
)
))
1 try
0 git … commit --all --message\=2017-05-08\ 01\:10
[master 03f269c8b701] 2017-05-08 01:10
1 file changed, 3 insertions(+), 2 deletions(-)
0 git … push -v --dry-run origin master\:refs/heads/master
Pushing to [email protected]:cescoferraro/dotfiles.git
To [email protected]:cescoferraro/dotfiles.git
798f05653e9e..03f269c8b701 master -> master
Removing (list "--dry-run")
0 git … commit --all --message\=2017-05-08\ 01\:11