Add an 'after successful fetch' hook?
Closed this issue · 8 comments
I would like to be able to refresh my Magit status buffer after this project finishes a fetch which returns new commits. Would a change to be able to add an after-hook be accepted? I'm pretty new to elisp, but this seems pretty simple.
As I've thought about this more, it seems like it may be challenging to identify the right Magit status buffers to refresh, and refreshing all of them is probably not ideal. I'll investigate what's available and do some noodling. Thanks!
What's the status on this ?
Because I would like to actually run a forge-pull after an auto-fetch,
I tried with an advice like this
(defun run-forge-pull (&optional ARG PRED)
(message "Hello")
(forge-pull)
)
(advice-add 'run-forge-pull :after 'projectile-git-autofetch-run)
but it did not work.
This would run after all projects have been fetched, and I think the default-directory
variable would be depending on what your current buffer is. I'm not using forge, but I assume you would have to be inside a specific project.
I assume you would want to run this for every project?
I could add a hook so you can configure your own function. Should this be executed for every project or just the ones that fetched something?
This should be quite simple, but I will likely not get to it before end of next week.
Ideally, I would like an hook that runs for every project that's fetch with a way to know it's path/git folder.
I have added two hook variables in branch feature/after-fetch-hooks
.
projectile-git-autofetch-after-fetch-hook
runs for every fetched repository, independently of new content.
projectile-git-autofetch-after-successful-fetch-hook
runs for every repository where new content was fetched.
Please let me know if this works for you.
They are working just fine !
Great, thank you for the confirmation - merged to master now.