libgit2 / libgit2/libgit2sharp

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

Aperta
#1,599 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C#
Stelle
3.5k
Fork
925
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Aggiungi il test di regressione fornito a FileHistoryFixture ed eseguilo su repository.Commits.QueryBy con il CommitFilter multi-branch. Traccia il percorso di QueryBy che gestisce IncludeReachableFrom e confronta il suo comportamento con i quattro commit previsti. Il lavoro è completato quando il test non genera più KeyNotFoundException e restituisce i quattro commit nell’ordine dichiarato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, git
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.