docs(betterer 📚): suggest a post-rewrite hook in the workflow docs#1186
docs(betterer 📚): suggest a post-rewrite hook in the workflow docs#1186camjackson wants to merge 1 commit into
Conversation
|
Nice, I love this, such a good idea to target rebase. Just trying to get my head around the flow and figure out if What do you think? |
|
Yeah, it did occur to me that maybe they need to be treated differently. The nice thing about precommit is that it happens (wait for it) before the commit is made, so betterer can sneak the results update into the commit via I did consider putting Also it's just ocured to me that amending a commit also triggers the post-rewrite hook so you'd end up running betterer again hahaha. From the docs it looks like git does actually pass a flag to the hook which allows you to check if the trigger was an amend or a rebase. I might add a check to my script so that it only runs on a rebase and not on an amend. Anyway I'm rambling now but broadly I agree that precommit and postrewrite are qualitatively different workflows. Maybe betterer should have a dedicated mode for postrewrite. Rather than |
Related to #1184.
In PR #1185 I've tried to make the CLI output clearer in the case where files have changed but test results have not.
This PR tries to get at the root cause. In my experience, when this happens, it's almost always because someone rebased their feature branch, pulling in new changes, and then pushed without re-running betterer. They may even have resolved merge conflicts in the results file while rebasing, but really what you need to do is run betterer again after the rebase has finished to make sure it's totally up to date.
I've been able to accomplish that with a post-rewrite hook in my codebase. This PR adds a line to the docs to suggest that as part of the betterer workflow.
Here's what it looks like in the docs site running locally on my laptop:
To complete the picture, this is the post-rewrite hook that I've created in my codebase:
When it fails it looks like this: