libgit2 / libgit2/libgit2sharp
Unable to iterate commits on all branches for a specific path (KeyNotFoundException)
未关闭
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 3.5k
- 派生
- 925
- PR 合并指标
- 30 天内没有已合并 PR
描述
When you attempt to use repository.QueryBy(string, CommitFilter) and specify all branches as the IncludeReachableFrom parameter, a KeyNotFound exception is thrown.
Reproduction steps
Add the following test to FileHistoryFixture to reproduce the issue
[Fact]
public void CanListChangesThatIncludeMultipleBranches()
{
var repoPath = CreateEmptyRepository();
const string path1 = "Test1.txt";
const string path2 = "Test2.txt";
using (var repo = new Repository(repoPath))
{
// Make initial changes.
var initial = MakeAndCommitChange(repo, repoPath, path1, "Hello World", "initial commit");
MakeAndCommitChange(repo, repoPath, path2, "Goodbye world", "unrelated file change 1");
var update1 = MakeAndCommitChange(repo, repoPath, path1, "Hello World!", "added punctuation");
var branch = repo.CreateBranch("branch");
Commands.Checkout(repo, branch);
var branchUpdate = MakeAndCommitChange(repo, repoPath, path1, "Hello World again", "branch change");
MakeAndCommitChange(repo, repoPath, path2, "Goodbye cruel world", "unrelated file change 2");
Commands.Checkout(repo, repo.Branches["master"]);
var update2 = MakeAndCommitChange(repo, repoPath, path1, "Hola Mundo", "switching to spanish");
var commits = repo.Commits
.QueryBy(path1, new CommitFilter { IncludeReachableFrom = repo.Branches, SortBy = CommitSortStrategies.Topological})
.ToList();
Assert.Equal(4, commits.Count);
Assert.Equal(branchUpdate.Sha, commits[0].Commit.Sha);
Assert.Equal(update2.Sha, commits[1].Commit.Sha);
Assert.Equal(update1.Sha, commits[2].Commit.Sha);
Assert.Equal(initial.Sha, commits[3].Commit.Sha);
}
}
Version of LibGit2Sharp (release number or SHA1)
f8e2d42ed9051fa5a5348c1a13d006f0cc069bc7
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
将提供的回归测试添加到 FileHistoryFixture,并使用 multi-branch CommitFilter 针对 repository.Commits.QueryBy 运行它。跟踪处理 IncludeReachableFrom 的 QueryBy 路径,并将其行为与预期的四个提交进行比较。当测试不再抛出 KeyNotFoundException,并按断言的顺序返回这四个提交时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, git
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100