Closed jwatzman closed 1 year ago
If you were invoking the post-commit hook then spr could become quite slow because it can create a couple commits each time you use it.
Right -- despite creating commits under the hood, what we're doing here is morally a rewrite. (Not that git itself distinguishes between those anyway!)
It's a bit strange that spr would invoke post-rewrite but not other hooks, but I think that's ok.
We can always add the others as/if we need!
Other thing to consider is whether to have a flag in the config that decides whether this hook should run or not. I think that that might actually be a good idea. Mostly because I expect most people will not care about hooks for commits that spr creates. However, I don't feel strongly about this.
Running the hooks seems like a reasonable default behaviour, but if it's a problem, can add the options in a future PR.
This is something that libgit2 (deliberately) does not do and leaves up to application authors. It's useful for us to do, to, e.g., inform things like git-branchless (https://github.com/arxanas/git-branchless) what has happened when we rewrite commits. And it's easy enough, there is a crate specifically to do this for us.
We may want to do something similar for
rebase_commits
too, but this was the one that was causing me grief for now.Test Plan: use
spr amend
on a repo alongside the aforementioned git-branchless. Its post-rewrite hook is invoked and its data structures are updated correctly.