feat: 支持 --commit 多哈希合并审查#8
Open
huanxue318 wants to merge 1 commit into
Open
Conversation
支持通过逗号分隔的多个 commit 哈希进行合并审查,适用于个人多次 提交之间夹杂他人提交的场景。 主要改动: - 新增 internal/diff/merge.go:实现 MergeDiffs 多 commit diff 合并逻辑 - 新增 internal/diff/merge_test.go:合并逻辑单元测试 - internal/diff/git.go:新增 ModeMultiCommit、NewMultiCommitProvider、 getMultiCommitDiff 方法 - internal/agent/agent.go:loadDiffs 支持逗号分隔 commit 路由到 MultiCommitProvider - cmd/opencodereview/review_cmd.go:FileReader.Ref 使用最后一个 commit 哈希 - cmd/opencodereview/flags.go:更新 --commit 用法说明 - cmd/testdiff/main.go:测试工具支持多 commit - 更新 README.md、README.zh-CN.md、NPM-README.md 使用说明 - 更新 SKILL.md、.claude/commands、plugins/commands 配套文档 用法:ocr review --commit abc123,def456
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.
关联 Issue
Closes #7
使用场景
当修复某个问题时,可能一次没有 commit 完全,期间又有其他人 commit 了,因此需要对个人的多次 commit 进行合并审查。
实现方案
采用纯 diff 合并方式,保持项目只做只读 git 操作的设计原则:
git show,解析为[]model.Diff向后兼容
--commit abc123(单个哈希)行为完全不变,只有传入逗号分隔的多个哈希时才走新的合并路径。主要改动
internal/diff/merge.goMergeDiffs多 commit diff 合并逻辑internal/diff/merge_test.gointernal/diff/git.goModeMultiCommit、NewMultiCommitProvider、getMultiCommitDiffinternal/agent/agent.goloadDiffs支持逗号分隔 commit 路由到MultiCommitProvidercmd/opencodereview/review_cmd.goFileReader.Ref使用最后一个 commit 哈希cmd/opencodereview/flags.go--commit用法说明cmd/testdiff/main.goREADME.md/README.zh-CN.mdNPM-README.mdSKILL.md.claude/commands//plugins/测试
单元测试
端到端测试
使用 testdiff 工具在本仓库验证: