libgit2 / libgit2/libgit2sharp

Unable to iterate commits on all branches for a specific path (KeyNotFoundException)

Offen
#1,599 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
C#
Sterne
3.5k
Forks
925
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Füge den bereitgestellten Regressionstest zu FileHistoryFixture hinzu und führe ihn mit dem Multi-Branch-CommitFilter gegen repository.Commits.QueryBy aus. Verfolge den QueryBy-Pfad, der IncludeReachableFrom verarbeitet, und vergleiche sein Verhalten mit den erwarteten vier Commits. Die Aufgabe ist erledigt, wenn der Test keine KeyNotFoundException mehr auslöst und die vier Commits in der behaupteten Reihenfolge zurückgibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp, git
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.