libgit2 / libgit2/libgit2sharp

Failed push not displaying pre-receive hook error message

Đang mở
#1,838 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ả

Executing a push that is rejected by the pre-receive hook on the server side, the OnPushStatusError notification is not displaying the error message returning by the remote git server, it is just showing the generic error pre-receive hook declined.

Executing the same push but with the git command line, the message error is dsplayed correctly.

# git push origin master
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 12 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 504 bytes | 504.00 KiB/s, done.
Total 6 (delta 2), reused 0 (delta 0)
remote: GL-HOOK-ERR: MY SPECIFIC ERROR MESSAGE
To https://nsgitlab/pablo.nardone/test3.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://nsgitlab/pablo.nardone/test3.git'
Reproduction steps

Setup a pre-receive hook that reject the push with some specific error message. In my case the message is GL-HOOK-ERR: MY SPECIFIC ERROR MESSAGE. Execute from command line git push origin master and verifiy the push si rejected and the specific error message is displayed correctly. Execute the same push operation but this time with the LibGit2Sharp library and verify the push is rejected but only displaying the generic error pre-receive hook declined and not the specific error returning by the pre-receive hook.

try
{
	PushOptions options = new PushOptions
	{
		OnPushStatusError = (PushStatusError pushStatusErrors) =>
		{
			throw new Exception($"OnPushStatusError - Reference({pushStatusErrors.Reference}) Message({pushStatusErrors.Message})");
		},
	};
	repo.Network.Push(branch, options);
}
catch (Exception ex)
{
	Debug.WriteLine(ex.Message);
}
Expected behavior
OnPushStatusError - Reference(refs/heads/master) Message(pre-receive hook declined. GL-HOOK-ERR: MY SPECIFIC ERROR MESSAGE)
Actual behavior
OnPushStatusError - Reference(refs/heads/master) Message(pre-receive hook declined)
Version of LibGit2Sharp (release number or SHA1)

LibGitSharp 0.26.2

Operating system(s) tested; .NET runtime tested

Windows 10 Pro, .NET 4.7.2

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

Bắt đầu từ PushOptions.OnPushStatusError và entry point repo.Network.Push được nêu trong phần tái hiện, sau đó theo dõi cách thông báo từ chối của remote đến PushStatusError.Message. Tái hiện lỗi của pre-receive hook và so sánh callback của thư viện với output trên dòng lệnh. Hoàn tất khi callback bao gồm cả thông báo từ chối chung và thông báo cụ thể của hook.

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
Khá rõ ràng
Mức phù hợp với người mới
35/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.