b4 feature request: run command before rewriting history
Hi Konstantin
I recently started switching my workflow over to 'b4 prep' for preparing patches, and am loving the workflow. Thanks a lot for working on this!
However, I ran into one little snag, that I'm hoping could be fixed with a new b4 feature: I am also a big fan of 'stacked git' (stgit)[0], and often use that instead of 'rebase -i' when preparing a series for submission.
So naturally, I want to combine 'b4 prep' with stgit. The problem here is that stgit maintains its own state for the branches it manages, and gets awfully confused if the git history is rewritten underneath it. It's still possible to use it with 'b4 prep', as long as I remember to do 'stg commit --all' before running any of the b4 commands. And, well, guess what I already forgot several times? :)
So, my feature request is this: add support to b4 for a hook command that is executed before any operation that will rewrite history - and abort the rewriting if the command fails. That way, I can make sure that I don't forget to clear the stgit state before running b4, saving me from the pain of dealing with a confused tool.
Do you think this would be feasible to implement?
Many thanks!
-Toke
Quoted 17 lines · Toke Høiland-Jørgensen
Hi Konstantin
I recently started switching my workflow over to 'b4 prep' for preparing patches, and am loving the workflow. Thanks a lot for working on this!
However, I ran into one little snag, that I'm hoping could be fixed with a new b4 feature: I am also a big fan of 'stacked git' (stgit)[0], and often use that instead of 'rebase -i' when preparing a series for submission.
So naturally, I want to combine 'b4 prep' with stgit. The problem here is that stgit maintains its own state for the branches it manages, and gets awfully confused if the git history is rewritten underneath it. It's still possible to use it with 'b4 prep', as long as I remember to do 'stg commit --all' before running any of the b4 commands. And, well, guess what I already forgot several times? :)
Quoted 7 lines
So, my feature request is this: add support to b4 for a hook command that is executed before any operation that will rewrite history - and abort the rewriting if the command fails. That way, I can make sure that I don't forget to clear the stgit state before running b4, saving me from the pain of dealing with a confused tool.
Do you think this would be feasible to implement?
Hi Konstantin
Friendly ping on the above? :)
-Toke
Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 1 line
Do you think this would be feasible to implement?
Hi Konstantin
Friendly ping on the above? :)
Yeah, I hope to be able to look into this in the near future. Unfortunately, I've been dealing with less-than-pleasant tasks such as ddos attacks and trolls over the past couple of weeks, but at least it's finally on the wane as people move on.
-K
Quoted 11 lines · Konstantin Ryabitsev
Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 1 line
Do you think this would be feasible to implement?
Hi Konstantin
Friendly ping on the above? :)
Yeah, I hope to be able to look into this in the near future. Unfortunately, I've been dealing with less-than-pleasant tasks such as ddos attacks and trolls over the past couple of weeks, but at least it's finally on the wane as people move on.
Right, no worries, just wanted to make sure this didn't get lost entirely. Thanks for looking at it! :)
-Toke
Quoted 9 lines · Toke Høiland-Jørgensen
Quoted 7 lines · Konstantin Ryabitsev
Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 1 line
Do you think this would be feasible to implement?
Hi Konstantin
Friendly ping on the above? :)
Quoted 7 lines
Quoted 4 lines
Yeah, I hope to be able to look into this in the near future. Unfortunately, I've been dealing with less-than-pleasant tasks such as ddos attacks and trolls over the past couple of weeks, but at least it's finally on the wane as people move on.
Right, no worries, just wanted to make sure this didn't get lost entirely. Thanks for looking at it! :)
Hi Konstantin
Another friendly ping on this? :)
-Toke
Quoted 16 lines · Toke Høiland-Jørgensen
Quoted 14 lines · Toke Høiland-Jørgensen
Quoted 11 lines · Konstantin Ryabitsev
Quoted 5 lines · Toke Høiland-Jørgensen
Quoted 1 line
Do you think this would be feasible to implement?
Hi Konstantin
Friendly ping on the above? :)
Yeah, I hope to be able to look into this in the near future. Unfortunately, I've been dealing with less-than-pleasant tasks such as ddos attacks and trolls over the past couple of weeks, but at least it's finally on the wane as people move on.
Quoted 6 lines
Quoted 2 lines
Right, no worries, just wanted to make sure this didn't get lost entirely. Thanks for looking at it! :)
Hi Konstantin
Another friendly ping on this? :)
Only a year later, finally adding this to the tracker. I'm sure you've given up, but this has been sitting in my inbox for a while, shaming me.
bugspray tag b4/prep
Signature · 1 line
KR
Hello:
This conversation is now tracked by b4 bug tracker. There is no need to do anything else, just keep talking.
--
Deet-doot-dot, I am a bot.
b4 bug tracker (bugspray 0.1-dev)
Konstantin Ryabitsev writes in commit bc6c4d853c7eace3b7f325cbd17dfe2d67760fb7:
prep: add pre/post history-rewrite hooks
Add two new configuration keys, prep-pre-rewrite-hook and prep-post-rewrite-hook, that let users run a command before and after any b4 operation that rewrites history on a prep branch.
The pre-hook runs before the rewrite and aborts the operation if it exits non-zero. The post-hook runs after a successful rewrite; a non-zero exit is logged as a warning but does not undo anything.
The primary use case is Stacked Git: users can set prep-pre-rewrite-hook to "stg commit --all" so that StGit's internal state is cleared before b4 modifies the branch, and prep-post-rewrite-hook to "stg repair" to re-sync afterwards.
Hooks are called around git-filter-repo runs in run_frf(), which covers all history rewrites on existing prep branches: cover letter updates, trailer updates, and reroll cover rewrites.
Key changes:
- New run_rewrite_hook() helper in ez.py
- Instrumented run_frf() with pre/post hooks around frf.run()
- Added 6 unit tests for the hook mechanism
- Documented both config keys in docs/config.rst
--
Deet-doot-dot, I am a bot.
b4 bug tracker (bugspray 0.1-dev)