libgit2 / libgit2/libgit2sharp
Issue adding tracking branch with sparse checkout in Jenkins
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ả
I've replicated an issue we have when running Gitversion (that uses this library) inside a Jenkins checkout step. Jenkins is running with space checkout.
I've created a test repository with the code in question, that I've replicated from the test case https://github.com/libgit2/libgit2sharp/blob/v0.26.1/LibGit2Sharp.Tests/BranchFixture.cs#L719L749
The code in question to create a local branch and set it to track it's remote is this:
using (var repo = new Repository("."))
{
var remoteRefName = "refs/remotes/origin/master";
var branchName = "master";
var remoteBranch = repo.Branches[remoteRefName];
var localBranch = repo.Branches[branchName];
if (localBranch == null)
{
localBranch = repo.CreateBranch(branchName, remoteBranch.Tip);
}
repo.Branches.Update(localBranch, b =>
{
b.TrackedBranch = remoteBranch.CanonicalName;
});
}
taken from https://github.com/joaomatossilva/libgitsharp-issue/blob/master/TestApp/Program.cs
The reproduction commands were taken out of a log from Jenkins build
Reproduction steps
Execute the following steps on a clean directory:
git init
git config remote.origin.url https://github.com/joaomatossilva/libgitsharp-issue.git
git config --add remote.origin.fetch +refs/pull/1/head:refs/remotes/origin/pr-1
git config --add remote.origin.fetch +refs/heads/master:refs/remotes/origin/master
git config remote.origin.url https://github.com/joaomatossilva/libgitsharp-issue.git
git fetch --force --progress -- https://github.com/joaomatossilva/libgitsharp-issue.git +refs/pull/1/head:refs/remotes/origin/pr-1 +refs/heads/master:refs/remotes/origin/master
git config core.sparsecheckout
git checkout -f 1bacdbeeda22863bbb8ba8f89dc933246bd4944c
dotnet run --project ./TestApp/TestApp.csproj
Expected behavior
It would be expected to have the same behaviour as
git branch --set-upstream-to=origin/master master
Actual behavior
Unhandled Exception: LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/master' doesn't match the destination
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 136
at LibGit2Sharp.Core.Proxy.git_refspec_rtransform(IntPtr refSpecPtr, String name) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 2076
at LibGit2Sharp.Remote.FetchSpecTransformToSource(String reference) in C:\projects\libgit2sharp\LibGit2Sharp\Remote.cs:line 135
at LibGit2Sharp.BranchUpdater.GetUpstreamInformation(String canonicalName, String& remoteName, String& mergeBranchName) in C:\projects\libgit2sharp\LibGit2Sharp\BranchUpdater.cs:line 188
at LibGit2Sharp.BranchUpdater.SetUpstream(String upstreamBranchName) in C:\projects\libgit2sharp\LibGit2Sharp\BranchUpdater.cs:line 118
at TestApp.Program.<>c__DisplayClass0_0.<Main>b__0(BranchUpdater b) in C:\temp\git-issue\TestApp\Program.cs:line 25
at LibGit2Sharp.BranchCollection.Update(Branch branch, Action`1[] actions) in C:\projects\libgit2sharp\LibGit2Sharp\BranchCollection.cs:line 292
at TestApp.Program.Main(String[] args) in C:\temp\git-issue\TestApp\Program.cs:line 23
Version of LibGit2Sharp (release number or SHA1)
0.26.1
Operating system(s) tested; .NET runtime tested
Windows 10, .Net core 2.2
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với các lệnh tái hiện và bài kiểm thử liên quan trong LibGit2Sharp.Tests/BranchFixture.cs, sau đó lần theo stack trace qua BranchUpdater.cs và Remote.cs. So sánh hành vi của sparse-checkout với lệnh git branch --set-upstream-to dự kiến, đồng thời thêm hoặc cập nhật một bài kiểm thử hồi quy cho thấy các tracking refs được xử lý chính xác.
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
- devtools
- 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
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100