libgit2 / libgit2/libgit2sharp

Failed push not displaying pre-receive hook error message

未關閉
#1,838 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
C#
星號
3.5k
分支
925
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 PushOptions.OnPushStatusError 和重現中顯示的 repo.Network.Push 入口點開始,然後追蹤遠端拒絕訊息如何到達 PushStatusError.Message。重現 pre-receive hook 失敗,並比較函式庫回呼與命令列輸出。當回呼同時包含一般拒絕訊息和 hook 的特定訊息時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
csharp, git
領域
devtools
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。