Repository navigation
fix(git): compare file context branches in their repository - #2573
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…re-branch Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # scripts/desktop/build-desktop-core.sh
…re-branch Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # scripts/desktop/build-desktop-core.sh
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Note
Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.
Devin Review found 1 finding. Devin was interrupted while fixing; 1 finding is left for you to triage below.
| var files []core.GitComparisonFile | ||
| var err error | ||
| if len(exactPaths) > 0 { | ||
| files, err = kernel.GitExactComparison(ctx, root, base, target, exactPaths...) |
There was a problem hiding this comment.
🟡 File comparison opens the deleted spelling
With core.ignorecase enabled, GitExactComparison returns both spellings when Git reports a case-only rename as a deletion and addition. If the deleted spelling sorts first, openComparisonDiff opens it instead of the selected file.
Learn more
The file menu passes exactly one repository-relative path to compareReferencesAt. Core uses a case-insensitive Git pathspec and compares lowercased path keys when core.ignorecase is enabled. If Git cannot pair a case-only rename because the file content changed too much, Core retains the separate addition and deletion under their original spellings. openComparisonDiff opens the first returned path, and loadDiffAs requests a diff for that spelling alone.
Example: A branch has README.md. The working tree contains a staged case-only rename to readme.md with fully replaced contents. Selecting readme.md and comparing against that branch returns both entries and opens the deletion of README.md first.
Recommended fix: In Core’s exact-path result selection, prefer a byte-for-byte path match when one requested path matches multiple returned entries after normalization. Keep normalized matching as a fallback for paths with no exact spelling, and test a case-only rename with low enough similarity for Git to return an addition and deletion.
Was this helpful? React with 👍 or 👎 to provide feedback.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
文件右键菜单里的「Git ▸ 与分支比较」应当只比较被右键的文件,并使用这个文件所在仓库的分支。修复前它总是比较整个仓库工作区;在嵌套多仓库工作区里,它还错误地使用 Git 日志当前仓库的分支和文件列表。
改动 / Changes
git.comparison的桌面端 typed client 增加可选 literalpathspecs透传;未传路径的既有调用保持仓库级比较不变。repositoryOwningFile找最深的嵌套仓库,分支列表取自该仓库:日志当前仓库用p.log.refs,非当前仓库用已读入的 nested reference cache。compareReferencesAt,因此比较结果只包含该文件;没有差异时仍走已有 “no differences” 通知。gitCompareMenu行为,不改成单路径过滤。PINNED_CORE_REVISION升到b0405313d030d4a9e4439c3b1568578db31bdce1:这是 Core PR fix(windows): align workbench layout with IDEA #242 分支合并当前 Core main 后的提交,既包含 pathspecs 修复,也不丢弃桌面当前 main 依赖的 Core 基线。z-target.txt,嵌套仓库 B 只列出并使用 B 的only-b。不在本 PR 范围内 / Out of scope
跨仓库依赖:Core PR #242 尚未合入。本 PR 不假定它已经进 Core main;当前 pin 指向 #242 分支与 Core main 的合并提交
b0405313d030d4a9e4439c3b1568578db31bdce1。维护者合入 Core 后如需只跟踪 main,可在后续把 pin 换成对应的 Core main commit。类型专属:fix
复现与根因
a-first.txt和z-target.txt在目标分支都有差异,右键z-target.txt选择「Git ▸ 与分支比较」。修复前列出 2 个文件并先打开a-first.txt;期望只列出并直接打开z-target.txt。嵌套多仓库中右键 B 仓库文件,修复前列出根仓库 A 的分支;期望列出 B 的分支。git log -S或git blame查):Viva 迁移 Epic(0.7.0): 基于 Viva 框架的跨平台方案的迁移(#1794) #1799 引入的git.comparison调用没有路径维度;feat(menu): 右键菜单按 IDEA 重新分组、补图标和缺失项,插件输出并入运行窗口 #2551 重组菜单后文件菜单仍直接使用日志仓库的p.log.refs和仓库级compareReferences。检查项
desktop/internal/workbench/gitcompare_test.go修复前单仓库comparison Diff tab = <nil>, want z-target.txt alone,嵌套仓库the branch menu does not list the nested repository's own branches;desktop/internal/core/git_review_test.go与 Core fixture 测试修复后通过.agents/notes/implemented/bug-fix/记录:未引入新的长期架构取舍;约束由两个右键菜单回归测试固定范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/git-branches-remotes.json:两端的实现状态和验证状态、证据路径、owner、验证动作都如实填写;没有运行验证的保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh;改了平台实现路径的,还运行了./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图matrix-exempt标签只能由 reviewer 给已审查、且没有用户可观察变化的重构添加,作者不要自行声明):已更新git-branches-remotes插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;插件的构建步骤、资源路径和补丁没有写进docs/ci-builds.md、Agent Note 或 SkillUI 验证 / UI evidence
77e80211d、Core pinb0405313d030d4a9e4439c3b1568578db31bdce1下按两个中文菜单场景复测并检查截图说明:Diff UI 只有多文件比较才渲染文件切换/计数;截图中直接打开目标文件且无多文件计数,即证明比较只含该文件。
统一日志系统 / Structured logging
N/A:没有新增生命周期里程碑、终态、降级、自动恢复或失败路径;比较失败仍走已有通知与
operationFailed边界。界面文案 / i18n
N/A:没有新增或修改用户可见文案;仍使用既有
desktop.files.compareBranch等共享 i18n 词条。逻辑归属 / Logic placement
refactorIssue:路径过滤与 literal pathspec 校验在 Core PR fix(windows): align workbench layout with IDEA #242,宿主只决定文件归属并传参性能与内存 / Performance and memory
设置 / Settings
N/A:没有新增或修改设置项、设置页、对话框选项或有标题的功能区。
插件契约 / Plugin contract
N/A:未修改
shared/plugins/contract/v1/、能力版本、插件函数协议、宿主方法或宿主通知。git.comparison是桌面宿主内部 Core command;桌面端 pin 已升到 Core PR #242 的 commit,未使用插件 SDK 协议。发行包与资源 / Bundle and resources
N/A:没有新增或修改运行时资源、缓存、下载物、解压物、日志、锁文件或构建资源;
PINNED_CORE_REVISION只替换既有 Core 输入 commit。无用代码与重构 / Dead code and refactoring
refactor标签的 Issue,没有在本 PR 顺手处理:未发现需要本次建单的既有无用代码;发现的同级仓库菜单缺陷是行为 bug,已建 [Bug] 同级多仓库工作区中文件右键菜单缺少 Git 子菜单 #2569验证 / Verification
./scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestWorkflowOutputProgressUpdatesAndRelease$' -count=1./scripts/desktop/desktop-go.sh test ./...internal/workbench的TestWorkbenchWindowClosingPersistsResizedAndMaximizedGeometry/resized_back_to_opening_size_does_not_write_settings_on_close外全部通过;该用例单独重跑仍失败。本 PR diff 不涉及窗口几何代码,需按 main 上的既有稳定性单独处理./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEADgit diff --check origin/main...HEAD.artifacts/desktop/bin/lithe,最终 Core pinb0405313lithe/lithe-mcp进程残留未能执行的检查和原因: macOS/Windows 原生验收未执行;当前环境是 Linux。共享 Viva 代码同一实现覆盖两端,ready 后 CI 将执行平台检查。
提交前确认 / Final checks
main创建;目标分支:feat、fix、docs 为main,release 以发布流程要求为准.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图Link to Devin session: https://app.devin.ai/sessions/40fd0cdabd664dafadc0c1783ea1cb59
Open in Devin Desktop: https://app.devin.ai/desktop/session/40fd0cdabd664dafadc0c1783ea1cb59?variant=devin
Requested by: @1lck
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work