Failed push not displaying pre-receive hook error message

Offen
#1,838 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
csharp, git
Bereich
devtools

Rechercherichtung

Beginne bei PushOptions.OnPushStatusError und dem repo.Network.Push-Einstiegspunkt, der in der Reproduktion gezeigt wird, und verfolge dann, wie die Ablehnungsnachricht des Remotes PushStatusError.Message erreicht. Reproduziere den Fehler des pre-receive hook und vergleiche den Bibliotheks-Callback mit der Command-Line-Ausgabe. Erledigt ist es, wenn der Callback sowohl die generische Ablehnung als auch die spezifische Nachricht des Hooks enthält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
C#
Sterne
3.5k
Forks
925
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus libgit2/libgit2sharp

Alle Issues in libgit2/libgit2sharp

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.