Skip to content

fix(git): compare file context branches in their repository - #2573

Merged
1lck merged 8 commits into
mainfrom
devin/2550-file-compare-branch
Dec 2, 2026
Merged

1lck merged 8 commits into
mainfrom
devin/2550-file-compare-branch

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

关联 Issue / Linked issue

PR 类型 / Type

  • feat:新功能或用户可见的改进
  • fix:缺陷修复
  • docs:文档、Agent Note、Skill 等规则文件
  • release:稳定版发布准备

改动说明 / What changes

背景 / Why

文件右键菜单里的「Git ▸ 与分支比较」应当只比较被右键的文件,并使用这个文件所在仓库的分支。修复前它总是比较整个仓库工作区;在嵌套多仓库工作区里,它还错误地使用 Git 日志当前仓库的分支和文件列表。

改动 / Changes

  • git.comparison 的桌面端 typed client 增加可选 literal pathspecs 透传;未传路径的既有调用保持仓库级比较不变。
  • 文件右键的「与分支比较」改为通过 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 基线。
  • 增加宿主 Core client 测试和两个无头右键菜单回归测试:单仓库只打开 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

复现与根因

检查项

  • 已先写回归测试,确认它在修复前失败、修复后通过;测试路径与修复前的失败输出: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 测试修复后通过
  • [N/A] 无法自动化时,已写明手动复现与验证步骤:已自动化;另已用真实 Linux 桌面按 issue 原场景复测
  • 已搜索被修改函数、类型、契约字段的全部调用方(含另一平台、插件、SDK、脚本和按字符串分发的调用)
  • 已检查另一平台是否有同类缺陷(有则本 PR 一并修复,或已提交 Issue):共享 Viva 实现,同一修复覆盖 macOS/Windows/Linux;仅有 Linux 实机验证
  • 只改了修复所需的代码,没有夹带重构;修复过程中发现的其他问题已提交 Issue:[Bug] 同级多仓库工作区中文件右键菜单缺少 Git 子菜单 #2569
  • [N/A] 修复改变了行为约束或容易复发,已在 .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/ 下生成的矩阵视图
  • [N/A] 没有更新矩阵的,理由(matrix-exempt 标签只能由 reviewer 给已审查、且没有用户可观察变化的重构添加,作者不要自行声明):已更新 git-branches-remotes

插件归属 / Plugin ownership

  • 已在仓库根目录运行 develop-lithe 第三节“插件归属与宿主零依赖”的自查命令,结果为空
  • 新增或修改的测试只使用测试内联的合成插件、Core 契约 fixture 或插件市场索引快照;没有读取具体插件的插件包、仓库检出、构建产物或清单,没有使用真实插件 ID,没有“缺少插件时跳过”的测试
  • 没有为具体插件提供的能力新建或更新宿主功能矩阵条目;宿主条目的证据和验证动作不引用插件的测试、插件包或插件仓库
  • 插件文案没有写进 shared/i18n/;插件的构建步骤、资源路径和补丁没有写进 docs/ci-builds.md、Agent Note 或 Skill
  • [N/A] 修改了通用扩展点、可能影响已发布插件的,已在受影响插件的仓库运行它的测试,插件仓库与结果:未修改插件扩展点

UI 验证 / UI evidence

  • 已运行受影响场景的 Viva 无头测试,生成并检查对应本次实现的截图;测试命令、提交、场景、主题、语言和尺寸:无头命令见“验证”;真实 Linux Viva 桌面在本地 merge commit 77e80211d、Core pin b0405313d030d4a9e4439c3b1568578db31bdce1 下按两个中文菜单场景复测并检查截图
  • 已在本 PR 嵌入截图或附上可访问的已上传截图 artifact 链接(本机路径或通过日志不能替代):
场景 分支菜单 打开的 Diff
单仓库 单仓库分支菜单 单仓库 z-target diff
嵌套多仓库 嵌套仓库分支菜单 嵌套仓库 z-target-B diff
  • [N/A] 布局与视觉变化有改动前后对照,明暗主题、中英文及交互状态按影响范围覆盖;需要目标平台原生窗口验收的结果:菜单外观、布局和文案没有变化,只有菜单内容来源与点击行为变化;已覆盖 issue 指定的中文 Linux 场景,macOS/Windows 原生验收未执行

说明:Diff UI 只有多文件比较才渲染文件切换/计数;截图中直接打开目标文件且无多文件计数,即证明比较只含该文件。

统一日志系统 / Structured logging

N/A:没有新增生命周期里程碑、终态、降级、自动恢复或失败路径;比较失败仍走已有通知与 operationFailed 边界。

界面文案 / i18n

N/A:没有新增或修改用户可见文案;仍使用既有 desktop.files.compareBranch 等共享 i18n 词条。

逻辑归属 / Logic placement

  • 可共享的逻辑(解析、校验、默认值和“自动”值的解析、状态规则、错误码等)在 Rust Core,并且共享契约和 fixture 先于平台接入;平台层只做原生 I/O 和呈现
  • 修改平台层已有的可共享逻辑时已迁入 Core;本次确有理由不迁的,理由与 refactor Issue:路径过滤与 literal pathspec 校验在 Core PR fix(windows): align workbench layout with IDEA #242,宿主只决定文件归属并传参
  • 工具或运行时专属的知识放在插件或成熟上游,宿主和 Core 没有按工具名加分支

性能与内存 / Performance and memory

  • 功能、子进程、语言服务器、WebView 首次需要才启动;没有新增空闲轮询;缓存和缓冲有上限;关闭项目、窗口、面板、标签时释放独占资源
  • 主线程没有文件读写、目录遍历、进程启动;跨 C ABI、web view 只传增量或可见窗口
  • [N/A] 涉及启动、打开项目、输入、滚动、大文件、长输出或搜索的,已附改动前后的性能基线数据;新增运行时或大型依赖的,已写明对启动时间、常驻内存和安装包体积的影响:比较仍复用现有后台 Git 调用,并把 diff 范围缩小到单文件

设置 / 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


验证 / Verification

命令或操作 平台 结果
`./scripts/desktop/desktop-go.sh test ./internal/core ./internal/workbench -run 'Test(GitComparisonListsAndDiffsTheDifferingFiles FileCompareWithBranchLimitsComparisonToThatFile NestedRepositoryFileCompareWithBranchUsesItsOwnRepository)$' -count=1`
`./scripts/desktop/desktop-go.sh test -race ./internal/workbench -run 'Test(FileCompareWithBranchLimitsComparisonToThatFile NestedRepositoryFileCompareWithBranchUsesItsOwnRepository)$' -count=1` Linux x86_64,最终分支与 Core pin
./scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestWorkflowOutputProgressUpdatesAndRelease$' -count=1 Linux x86_64 通过(覆盖上一轮 CI 的 panic 场景)
./scripts/desktop/desktop-go.sh test ./... Linux x86_64 除 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 Linux x86_64 通过(validated 234 platform capabilities)
./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD Linux x86_64 通过
git diff --check origin/main...HEAD Linux x86_64 通过
真实 Linux Viva 桌面复测单仓库与嵌套多仓库场景 Linux x86_64,重建 .artifacts/desktop/bin/lithe,最终 Core pin b0405313 通过;证据截图嵌入上方,录屏文件保留在会话交付中
进程清理 Linux x86_64 复测后无 lithe/lithe-mcp 进程残留

未能执行的检查和原因: macOS/Windows 原生验收未执行;当前环境是 Linux。共享 Viva 代码同一实现覆盖两端,ready 后 CI 将执行平台检查。

提交前确认 / Final checks

  • 分支从最新的 main 创建;目标分支:feat、fix、docs 为 main,release 以发布流程要求为准
  • 以 Draft 提交,本地验证通过后才标记 ready
  • 没有无关改动,没有提交 .build/、target/、dist/、.artifacts/ 等产物,没有凭据、个人路径和未脱敏的日志或截图
  • 本次构建、测试或预览启动的 Lithe 应用和子进程已全部关闭,没有进程残留

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

Devin Review

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@ghfind-review ghfind-review Bot added the review: no-score ghfind author score missing (not zero) label Dec 1, 2026
1lck and others added 3 commits December 1, 2026 04:17
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
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review December 2, 2026 06:13
1lck and others added 2 commits December 2, 2026 06:38
…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>
devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

View findings in Devin Review · Follow Devin's work

Devin Review

var files []core.GitComparisonFile
var err error
if len(exactPaths) > 0 {
files, err = kernel.GitExactComparison(ctx, root, base, target, exactPaths...)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@1lck
1lck merged commit dfc05a5 into main Dec 2, 2026
8 of 11 checks passed
@1lck
1lck deleted the devin/2550-file-compare-branch branch December 2, 2026 08:48

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: no-score ghfind author score missing (not zero)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant