-
Notifications
You must be signed in to change notification settings - Fork 25
Add automatic pull support #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Hey! Thanks for this pull request :) I'm glad to hear that you're found git-auto-commit-mode to be a useful project. The code basically looks good, I just have one question which I'll post inline. |
git-auto-commit-mode.el
Outdated
(when (and (buffer-live-p buffer) | ||
(or (and gac-automatically-add-new-files-p | ||
(not (gac--buffer-is-tracked buffer))) | ||
(gac--buffer-has-changes buffer))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the buffer-live-p
, are these the requirements you actually want?
For pushing it doesn't make sense to push when there won't be any changes to push, but technically there could be changes to pull regardless of whether or not this file is actually part of the git repository.
On the other hand I can also understand if it seems like overkill (and slow) to try and pull every single time if committing and pushing aren't going to happen either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I delayed on suggesting that this is final because there are some issues with merges that need to be resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chasecaleb thanks for the ping!
@kephale ok, so I'll wait until you let me know that everything is fine before merging this. What sort of issues are you having? And if they're caused by my comment than please disregard it and feel free to revert to the initial state you opened the review in.
Phew, sorry this took so long, but there were some subtle issues that required a continuous block of time to solve them all at the same time. Note that this looks quite a bit different than the previous iteration. One annoying thing I introduced is that since it uses a [edit] it looks replacing |
Hey :) That's alright, we all have busy lives and nobody is getting paid to work on this, things take time. And this doesn't seem like an easy issue to fix (after making changes, before saving, quickly pull changes which may affect the file you're trying to save). I don't think the problem is the call to (let ((process (start-process "git" "*git-auto-push*" "git" "push")))
(set-process-filter process #'gac-process-filter)
(set-process-sentinel process #'gac-process-sentinel)
(while (process-live-p process)
(accept-process-output process))) If |
I'm not sure how helpful this is, but if you haven't come across it you might want to check out how git-sync handles merge conflicts and so on. It's a bash script and I've been using it across multiple computers for quite a while. It does a good job of automatic pushing and warning on merge conflicts. |
Hi, I'm also using this minor mode with pleasure. To solve the problem with auto pulling before pushing, I use the following in my Doom Emacs config: (use-package! git-auto-commit-mode
:config
(setq-default gac-automatically-push-p t)
(setq-default gac-automatically-add-new-files-p t)
(defun gac-pull-before-push (&rest _args)
(let ((current-file (buffer-file-name)))
(shell-command "git pull")
(when current-file
(with-current-buffer (find-buffer-visiting current-file)
(revert-buffer t t t)))))
(advice-add 'gac-push :before #'gac-pull-before-push)) Should be working regardless of Doom. I only had to initially set the pull strategy. |
I have been happily using git-auto-commit-mode, but when the git repo is being worked on separately from different locations then I get merge conflicts when trying to auto push. This is a bit of a nuisance when doing something like working in a directory of org files and the conflicts are automatically mergable but it is easy to not notice that there was a merge conflict (plus it still requires manual resolution).
This PR introduces automatic pull support which runs in a before-save-hook. It works the same way as auto push, but simply pulls before the buffer is saved. It is also labeled as risky.