From 146a8f00d2f4288b3d98b82c261dd87101e5e741 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 6 Nov 2017 11:12:52 -0500 Subject: [PATCH] Actually get reference pushing working --- TGServerService/ServerInstance/Repository.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/TGServerService/ServerInstance/Repository.cs b/TGServerService/ServerInstance/Repository.cs index ecaf06020f..b3b92005d5 100644 --- a/TGServerService/ServerInstance/Repository.cs +++ b/TGServerService/ServerInstance/Repository.cs @@ -571,10 +571,11 @@ namespace TGServerService { if (Config.PushTestmergeCommits && SSHAuth()) { + string NewB = null; try { //now try and push the commit to the remote so they can be referenced - var NewB = Repo.CreateBranch(RemoteTempBranchName).CanonicalName; + NewB = Repo.CreateBranch(RemoteTempBranchName).CanonicalName; var options = new PushOptions() { @@ -582,14 +583,20 @@ namespace TGServerService }; var targetRemote = Repo.Network.Remotes[SSHPushRemote]; Repo.Network.Push(targetRemote, NewB, options); //push the branch - Repo.Network.Push(targetRemote, null, NewB, options); //delete the branch Repo.Branches.Remove(NewB); + NewB = null; + Repo.Network.Push(targetRemote, String.Format(":{0}", NewB), options); //delete the branch WriteInfo("Pushed reference commit: " + Repo.Head.Tip.Sha, EventID.ReferencePush); } catch (Exception e) { WriteWarning(String.Format("Failed to push reference commit: {0}. Error: {1}", Repo.Head.Tip.Sha, e.ToString()), EventID.ReferencePush); } + finally + { + if (NewB != null) + Repo.Branches.Remove(NewB); + } } }