libgit2 / libgit2/libgit2sharp

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

Đang mở
#1,599 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
C#
Star
3.5k
Fork
925
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Thêm regression test được cung cấp vào FileHistoryFixture và chạy nó với repository.Commits.QueryBy bằng CommitFilter multi-branch. Theo dõi đường đi của QueryBy xử lý IncludeReachableFrom và so sánh hành vi của nó với bốn commit mong đợi. Hoàn tất khi test không còn ném KeyNotFoundException và trả về bốn commit theo thứ tự được khẳng định.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, git
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.