Show HN: Tool to Automatically Create Organized Commits for PRs
76 points| edverma2 | 8 months ago |github.com
The tool sends the diff of your git branch against a base branch to an LLM provider. The LLM provider responds with a set of suggested commits with sensible commit messages, change groupings, and descriptions. When you explicitly accept the proposed changes, the tool re-writes the commit history on your branch to match the LLM's suggestion. Then you can force push your branch to your remote to make it match.
The default AI provider is your locally running Ollama server. Cloud providers can be explicitly configured via CLI argument or in a config file, but keeping local models as the default helps to protect against unintentional data sharing. The tool always creates a backup branch in case you need to easily revert in case of changing your mind or an error in commit re-writing. Note that re-writing commit history to a remote branch requires a force push, which is something your team/org will need to be ok with. As long as you are working on a feature branch this is usually fine, but it's always worth checking if you are not sure.
9dev|8 months ago
I’m all for proper commit messages, but only if they add clarity, not take it away.
diggan|8 months ago
Since models reacts so differently to different prompts, and people have different requirements, I feel like a basic requirement for a generally useful tool using LLMs should at least facilitate overriding both the system and user prompts wherever they're being used.
I remember coming across this with Aider as well, and seeing some things that were out of place (for me) in the prompts, but with no way of changing it, I had to rewire things myself so I could override them.
scottgg|8 months ago
[1] https://github.com/jj-vcs/jj
diggan|8 months ago
Never used jj, but isn't that just `git commit --amend`? Lets you add/remove/change changes from the previous commit by basically overwritting it with a new changeset+message.
amenghra|8 months ago
mindfulmark|8 months ago
adobrawy|8 months ago
stpedgwdgfhgdd|8 months ago
I’m fine that people squash as long the reasoning is recorded in comments and reflected through automated tests (unit AND system/api).
This is also crucial information for AI coding tools.
bredren|8 months ago
I make use of interactive partial commits using Pycharm when a single file has changes related to different ideas and rewrite history for clarity.
It does matter to me if someone else has gone to this trouble. And it is sometimes a tip off if a person is seemingly sloppy in commit history.
It makes sense that this project exists but I’m also glad it didn’t when I was learning to work in professional environments.
CityOfThrowaway|8 months ago
One thing I would love is if I could give it a hint and have it extract out certain types of changes into its own branch that could split into a new PR.
I often find myself adding a new, re-usable component or doing a small refactor in the middle of a project. When you're a few commits into a project and start doing side-quests, it's super annoying to untangle that work.
The options are one of:
1. A mega PR (which everybody hates) 2. Methodologically untangling the side quest post-hoc 3. Not doing it
In principle, the "right" thing to do would be to go checkout main, do the side quest, get it merged and then continue.
But that's annoying and I'd rather just jam through, have AI untangle it, and then stack the commits (ala Graphite).
It's easy to verbally explain what stuff is side-quest vs. main quest but it's super annoying to actually do the untangling.
Maybe this tool magically can do that... but I do wonder if some context hints from the dev would help / make it more effective.
matijsvzuijlen|8 months ago
Alternatively, if you don't like rebasing, you can merge the side quest branch into your project branch instead.
Either way, you don't have to wait for the side quest to get merged.
edverma2|8 months ago
2YwaZHXV|8 months ago
bananapub|8 months ago
How did you collate hundreds or thousands of examples of commits being split up and how did you score the results LLMs gave you? Or did it take more than that?
pabs3|8 months ago
https://github.com/tummychow/git-absorb
aaronbrethorst|8 months ago
esafak|8 months ago
jaredsohn|8 months ago
One huge advantage of squashing branches is if you see a commit in a `git blame` you might have an idea of where it came from within GitHub/Linear/other systems.
figmert|8 months ago
unknown|8 months ago
[deleted]
iandanforth|8 months ago
Fire-Dragon-DoL|8 months ago
So,where is the noise if it can be hidden but also used to get additional information on code changes?
CityOfThrowaway|8 months ago
1. Always squash and merge 2. But have tidy commits 3. So your squashed commit has a useful list of what is in the commit
collingreen|8 months ago
bredren|8 months ago
I think the intent is that it be up to the org to decide whether they’ll accept a stream of commits to merge or squash merge after approval.
kelseydh|8 months ago
Cthulhu_|8 months ago
bckr|8 months ago
3D39739091|8 months ago
maomaomiumiu|8 months ago
nrvn|8 months ago
> If the request is accepted, all commits will be squashed, and the final commit description will be composed by concatenating the pull request's title and description.
One less thing to think about.
Less is more, not vice versa.
[1]: https://go.dev/doc/contribute#review
f1shy|8 months ago
Linus Torvalds generally prefers not to squash commits when merging pull requests into the Linux kernel, especially when the individual commits have valuable information or context. He believes that squashing can discard useful history and make it harder to understand the evolution of the code. However, he also acknowledges that squashing can be useful in certain situations, such as when dealing with a large number of commits that are not relevant to the main development history
unknown|8 months ago
[deleted]
h1fra|8 months ago
jon-wood|8 months ago
It will forever infuriate me that Github's code review UI buries commits in favour of a big blob of changes without context, more so because that UI is generally considered Good Enough by most people, discouraging any innovation around code review.