fix(web): use blame line's path when navigating to commit diff#1178
fix(web): use blame line's path when navigating to commit diff#1178brendan-kellam merged 3 commits intomainfrom
Conversation
When a file has been renamed, blame lines may be attributed to commits where the file existed at a different path. Previously, clicking a commit in the blame gutter navigated using the current file path, which could resolve to a file that didn't exist at that commit. Capture the per-commit `filename` field from `git blame --porcelain` (emitted only on the first global appearance of each commit) and attach it as `path` to each blame range. Plumb it through `LineEntry` so the commit-click handler navigates to the correct historical path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughBlame ranges now include the historical file path (path) from git blame output. The parser emits ranges with path, the blame range schema and OpenAPI are updated, and the UI propagates {hash,path} through blame gutter handlers and navigation callbacks. ChangesBlame Path Tracking for Historical Navigation
Sequence Diagram(s)sequenceDiagram
participant User as User
participant UI as Browser UI
participant Router as Router
participant API as Server API
participant Parser as Git Blame Parser
participant Repo as Git Repo
User->>UI: Click blame gutter commit
UI->>Router: onCommitClick({hash, path})
Router->>API: Request file at commit (path, hash)
API->>Parser: parseBlame(path, hash)
Parser->>Repo: git blame --porcelain (path@hash)
Repo-->>Parser: blame output (includes filename metadata)
Parser-->>API: ranges with path populated
API-->>Router: file/commit response
Router-->>UI: Navigate to file view at commit
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
filenamefield fromgit blame --porcelain(emitted only on the first global appearance of each commit) and attach it aspathto each blame range.paththroughLineEntryandonCommitClickso the commit-click handler navigates to the correct historical path.While doing this I also discovered (and fixed) a parser bug: my first attempt assumed
filenamewas emitted on every group's metadata block, but porcelain only emits the metadata block on the first global appearance of each commit. The fix cachesfilenameper commit hash and looks it up when emitting each range. This was reproducible onlighthouse/test/syncYearlySubscription.test.ts, where commit4940d85bhas groups starting at lines 1 and 8 — line 8's group has no metadata block.🤖 Generated with Claude Code
Summary by CodeRabbit