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