fix(git): compress --stat histogram bars in git log output#698
Open
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
Open
fix(git): compress --stat histogram bars in git log output#698ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
ousamabenyounes wants to merge 1 commit intortk-ai:developfrom
Conversation
c4ae834 to
062e7a1
Compare
Contributor
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
062e7a1 to
dbcb62e
Compare
Contributor
Author
|
Rebased on |
dbcb62e to
4f16b02
Compare
Strip visual `++++----` bars from `git log --stat` output while preserving filenames, change counts, and the summary line. Reduces token usage by ~73%. Root cause: RTK's `---END---` format marker caused stat lines to appear at the start of commit blocks where `filter_log_output` mistook them for commit headers. Stat lines start with a leading space; this is now used to correctly split stat from commit content before processing. New functions: has_stat_flag, compress_stat_line, compress_stat_summary, compress_stat_block, split_stat_lines_from_block, extract_commit_entry. Adds 15 new unit tests; all 996 tests pass. Closes rtk-ai#611 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Ousama Ben Younes <benyounes.ousama@gmail.com>
4f16b02 to
e44ada8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
rtk git log --statpassed histogram bars (| 127 +++++++++++++++++++++++++) through uncompressed, consuming tokens unnecessarily.Root cause: RTK injects
---END---format markers between commits. When--statis active, git appends stat lines after the marker and before the next commit header.filter_log_outputsplits on---END---and treated the leading stat lines as commit headers, corrupting the output.Solution
Detect
--stat/--numstat/--shortstatflags and switch to a stat-aware block processing mode:has_stat_flag()— detects stat flags in argssplit_stat_lines_from_block()— splits stat prefix (leading-space lines) from the next commit headercompress_stat_line()—file.rs | 127 ++++→file.rs (127+)/(127-)/(127±)compress_stat_summary()—6 files changed, 705 insertions(+), 2 deletions(-)→6 files, +705 -2compress_stat_block()— compresses a full stat block, attaches it to the correct preceding commitOutput comparison
Before (raw passthrough, 3760 chars):
After (73% reduction, 989 chars):
Test plan
has_stat_flag,compress_stat_line,compress_stat_summary,compress_stat_block,filter_log_outputwithhas_stat=truecargo fmt --all --checkpassescargo clippy --all-targets— no new warnings (5 pre-existing ininit.rs)rtk git log --stat -3on this repoCloses #611
Signed-off-by: Ben Younes ousama.ben-younes@pm.me
🤖 Generated with Claude Code