Unable to iterate commits on all branches for a specific path (KeyNotFoundException)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Add the supplied regression test to FileHistoryFixture and run it against repository.Commits.QueryBy with the multi-branch CommitFilter. Trace the QueryBy path that handles IncludeReachableFrom and compare its behavior with the expected four commits. Done means the test no longer throws KeyNotFoundException and returns the four commits in the asserted order.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from libgit2/libgit2sharp
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
libgit2/libgit2sharp#2193 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
libgit2/libgit2sharp#2192 · 1 comment ·
-
Website is down Open
Difficulty 4/5 3-5 days Newbie friendliness 20/100
libgit2/libgit2sharp#2191 · 2 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
libgit2/libgit2sharp#2189 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
libgit2/libgit2sharp#2187 · 2 comments ·
All issues in libgit2/libgit2sharp
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
azurenoops/spin_agent#975 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·