From a7f4c22c52f7a949cb5be5614edb679bbce90db8 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 6 Nov 2017 11:27:57 -0500 Subject: [PATCH] Better failure handling for reference commit pushing --- TGServerService/ServerInstance/Repository.cs | 25 ++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/TGServerService/ServerInstance/Repository.cs b/TGServerService/ServerInstance/Repository.cs index 6ae37a3a31..1a1d1b4ca2 100644 --- a/TGServerService/ServerInstance/Repository.cs +++ b/TGServerService/ServerInstance/Repository.cs @@ -581,16 +581,15 @@ namespace TGServerService if (Config.PushTestmergeCommits && SSHAuth()) { string NewB = null; + var targetRemote = Repo.Network.Remotes[SSHPushRemote]; + var options = new PushOptions() + { + CredentialsProvider = GenerateGitCredentials + }; try { //now try and push the commit to the remote so they can be referenced NewB = Repo.CreateBranch(RemoteTempBranchName).CanonicalName; - - var options = new PushOptions() - { - CredentialsProvider = GenerateGitCredentials - }; - var targetRemote = Repo.Network.Remotes[SSHPushRemote]; Repo.Network.Push(targetRemote, NewB, options); //push the branch Repo.Branches.Remove(NewB); NewB = null; @@ -604,7 +603,19 @@ namespace TGServerService finally { if (NewB != null) - Repo.Branches.Remove(NewB); + { + //Try to delete the branches regardless + try + { + Repo.Branches.Remove(NewB); + } + catch { } + try + { + Repo.Network.Push(targetRemote, String.Format(":{0}", NewB), options); + } + catch { } + } } } }