PostCommit hook for pre-push
sluongng opened this issue · 2 comments
What
With Scalar, you can already prefetch
objects from the server onto hidden refs.
What if you can also pre-push
?
In Facebook's Eden (mercurial fork) extension Commit Cloud, commits are auto shared to the cloud in the background. User should be able to commit, share the commitID and other user should be able to immediately checkout/view that commit. See Talk in 2015 and 2019 for more information
How
We apply a PostCommit hook that would automatically push your commit after created in the background to a hidden refs onto the server. The refs name should be timestamped so we will never(or rarely) overwrite a past refs.
These refs is then included in the prefetch RefSpecs that other users may download in the background, thus effectively the commit is auto-synced across all client machines. This should also make user's git push
faster as no objects needed to be transferred on push and only the ref needed to be updated.
Server(outside of Scalar scope) should be equipped with a cron job that would clean up old PrePush
refs after a certain period(i.e. 5 working days) and related objects will become unreachable and picked up by GC.
This is an interesting idea, but not one I would anticipate using or recommending others to use. In particular, it requires server-side cleanup of these "hidden" refs. And if the ref is hidden, then how does one discover it on the server?
Since Azure Repos never GC's, I would avoid using ever this feature against that service.
This also seems like something that can be done in Git proper instead of in Scalar.
If you want to test and make a proof of concept, the microsoft/git fork has a concept of "post-command" hook that runs after every Git command, but could be used to recognize that a commit happened. That could help you make progress and prove the value of the idea before committing too much time to Git patches.
The talk from 2015 explicitly mentions that a cheap storage layer is used to store the commits that are not part of an "important" branch, which allows such a massive dump of every commit. Without that layer on the server side, this idea is unsafe.
I'm closing because this isn't just a Scalar issue, but an end-to-end system concern. Hopefully the post-command hook would provide a way for one to implement this if interested.