libgit2 / libgit2/libgit2sharp

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

Ouverte
#1,599 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
C#
Étoiles
3.5k
Forks
925
Métriques de merge des PR
Aucune PR mergée en 30 j

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Ajoutez le test de régression fourni à FileHistoryFixture et exécutez-le avec le CommitFilter multi-branch sur repository.Commits.QueryBy. Suivez le chemin QueryBy qui gère IncludeReachableFrom et comparez son comportement aux quatre commits attendus. La tâche est terminée lorsque le test ne lève plus KeyNotFoundException et renvoie les quatre commits dans l’ordre indiqué.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
csharp, git
Domaine
tooling
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.