git: Compress diff for commit message generation#42835
git: Compress diff for commit message generation#42835osyvokon merged 6 commits intozed-industries:mainfrom
Conversation
8ceac93 to
55259ff
Compare
Signed-off-by: 11happy <soni5happy@gmail.com> feat: implement diff compress Signed-off-by: 11happy <soni5happy@gmail.com>
Diffy lines already include the newline character, so calls like
`.join("\n")` result in doubled newlines, breaking the patch correctness
and making `compress_commit_diff` return an empty string.
841f4f5 to
36ff329
Compare
|
Thanks for implementing this! I've added some tests, and they didn't pass initially. Turns out, diffy lines already contain newlines character in them, so things like It's too bad that diffy doesn't support mutating hunks. This makes the code overly complex and less efficient, since we're reformatting the patch on every I think we can get rid of the dependency on diffy. Instead, let's just do simple diff string parsing. Essentially, we need two levels of parsing:
Then we can keep a list of hunks as a Are you willing to implement this change or should I go ahead? We can also pair on it, if you like. |
Yes, I am willing to implement this, I would request for a pair session if I face any difficulties. |
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
|
@osyvokon would appreciate your review! |
|
Looks much better now, thanks! I've made a few nit renames while reviewing this. Ready to merge. |
This PR compresses diff capped at 20000 bytes by: - Truncation of all lines to 256 chars - Iteratively removing last hunks from each file until size <= 20000 bytes. Closes #34486 Release Notes: - Improved: Compress large diffs for commit message generation (thanks @11happy) --------- Signed-off-by: 11happy <soni5happy@gmail.com> Co-authored-by: Oleksiy Syvokon <oleksiy@zed.dev>
This PR compresses diff capped at 20000 bytes by: - Truncation of all lines to 256 chars - Iteratively removing last hunks from each file until size <= 20000 bytes. Closes zed-industries#34486 Release Notes: - Improved: Compress large diffs for commit message generation (thanks @11happy) --------- Signed-off-by: 11happy <soni5happy@gmail.com> Co-authored-by: Oleksiy Syvokon <oleksiy@zed.dev>
This PR compresses diff capped at 20000 bytes by:
Closes #34486
Release Notes: