fix(git): parse git clone progress as log messages - #799
Conversation
📝 WalkthroughWalkthroughAdds a buffered git progress writer that parses carriage-return and newline output, suppresses duplicate or intermediate progress frames, forwards retained lines, and integrates the writer into clone stdout and stderr handling with tests. ChangesGit progress output handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant cloneWith
participant gitRunner
participant progressWriter
participant logWriter
cloneWith->>progressWriter: create from logWriter
cloneWith->>gitRunner: run clone with filtered stdout/stderr
gitRunner->>progressWriter: write git progress and informational output
progressWriter->>logWriter: forward retained lines
cloneWith->>progressWriter: close and flush buffered output
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
63333b3 to
e9d149c
Compare
…passthrough git clone already runs with --progress (added in #590), but its \r-delimited "Receiving objects: NN% (x/y)" frames were logged verbatim, producing a wall of near-duplicate lines for large clones. progressWriter splits on \r as well as \n (git overwrites its progress line with \r rather than emitting a new one), logs percentage updates thinned to one per 10 points, and passes any other line through unchanged.
e9d149c to
dff17d6
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
pkg/git/progress_test.go (1)
34-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the progress log cadence, not only forwarding suppression.
These tests cannot detect broken throttling because all progress frames are intentionally excluded from
out. Capture progress reports and assert the expected0%, 10%, …, 100%entries and independent labels.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/git/progress_test.go` around lines 34 - 77, Update TestProgressWriter_ThinsIntermediatePercentages, TestProgressWriter_DropsExactDuplicateFrame, and TestProgressWriter_TracksLabelsIndependently to capture progress reports through the writer’s progress-report mechanism instead of asserting only that out is empty. Assert the expected throttled 0%, 10%, through 100% cadence, verify exact duplicate frames are suppressed, and confirm Receiving objects and Resolving deltas maintain independent progress state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/git/progress.go`:
- Around line 30-40: Update progressWriter.Write so a flush failure returns the
number of bytes processed through the current delimiter, not len(p). Track the
delimiter’s index while iterating over p and return its delimiter-inclusive
offset alongside the error; preserve the existing successful return behavior.
In `@pkg/git/repo.go`:
- Around line 265-266: Update the clone flow around newProgressWriter and Run so
pw.Close() is called explicitly after Run, and return its error when the clone
succeeds. Remove the deferred Close that discards the trailing flush failure,
while preserving the clone error when Run fails.
---
Nitpick comments:
In `@pkg/git/progress_test.go`:
- Around line 34-77: Update TestProgressWriter_ThinsIntermediatePercentages,
TestProgressWriter_DropsExactDuplicateFrame, and
TestProgressWriter_TracksLabelsIndependently to capture progress reports through
the writer’s progress-report mechanism instead of asserting only that out is
empty. Assert the expected throttled 0%, 10%, through 100% cadence, verify exact
duplicate frames are suppressed, and confirm Receiving objects and Resolving
deltas maintain independent progress state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 26d196a9-3f75-47bc-b026-fc9f55a8bedd
📒 Files selected for processing (3)
pkg/git/progress.gopkg/git/progress_test.gopkg/git/repo.go
- progressWriter.Write now returns the byte offset through the delimiter it flushed at on a flush error, instead of len(p) -- satisfies the io.Writer contract that n reflects bytes actually consumed when err != nil. - cloneWith now calls progressWriter.Close() explicitly after Run and surfaces its error when the clone itself succeeded, instead of discarding a trailing-flush failure via a bare deferred Close. - Progress-writer tests now capture actual log output (via pkg/log.AddSink) and assert the real 0/10/.../100 thinning cadence, duplicate-frame suppression, and independent per-label state, instead of only asserting that percentage frames don't reach `next`.
✅ Deploy Preview for devsydev canceled.
|
✅ Deploy Preview for images-devsy-sh canceled.
|
git clone already runs with
--progress(added in #590), but its\r-delimited "Receiving objects: NN% (x/y)" frames were logged verbatim, producing a wall of near-duplicate lines for large clones.progressWritersplits git's output on\ras well as\n(git overwrites its progress line with\rrather than emitting a new one), logs percentage updates thinned to one per 10 points, and passes any other line through unchanged.Rebased off
maindirectly — no longer stacked on #798, and doesn't depend on its status/Reporter model. Progress is logged directly viapkg/loginstead of routed through a shared reporter abstraction, so this can merge independently.Summary by CodeRabbit
New Features
Bug Fixes