From 9acf4f1b4fb1549cc32186da8fc35d006029a482 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Wed, 15 Nov 2017 02:27:01 -0500 Subject: [PATCH] Fixes compiler crashing after completion --- TGS.Server/Instance/Compiler.cs | 2 +- TGS.Server/Instance/Repository.cs | 50 +++++++++++++++++++------------ 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/TGS.Server/Instance/Compiler.cs b/TGS.Server/Instance/Compiler.cs index 19d1ce2237..0ed5d2881b 100644 --- a/TGS.Server/Instance/Compiler.cs +++ b/TGS.Server/Instance/Compiler.cs @@ -371,7 +371,7 @@ namespace TGS.Server deleteExcludeList.Add(".git"); Helpers.CopyDirectory(RelativePath(RepoPath), resurrectee, deleteExcludeList); - CurrentSha = GetHead(false, out string error); + CurrentSha = GetShaOrBranchNoLock(out string error, false, false); //just the tip const string GitLogsDir = "/.git/logs"; Helpers.CopyDirectory(RelativePath(RepoPath + GitLogsDir), resurrectee + GitLogsDir); diff --git a/TGS.Server/Instance/Repository.cs b/TGS.Server/Instance/Repository.cs index 3f93681b5b..76cb247190 100644 --- a/TGS.Server/Instance/Repository.cs +++ b/TGS.Server/Instance/Repository.cs @@ -418,26 +418,38 @@ namespace TGS.Server error = "Repo is busy!"; return null; } - var result = LoadRepo(); - if (result != null) - { - error = result; - return null; - } - - try - { - error = null; - if (tracked && Repo.Head.TrackedBranch != null) - return Repo.Head.TrackedBranch.Tip.Sha; - return branch ? Repo.Head.FriendlyName : Repo.Head.Tip.Sha; - } - catch (Exception e) - { - error = e.ToString(); - return null; - } + return GetShaOrBranchNoLock(out error, branch, tracked); } + } + + /// + /// Gets the SHA or branch name of the 's HEAD. Requires + /// + /// on success, error message on failure + /// If , returns the branch name instead of the SHA + /// If , returns the tracked branch SHA and ignores + /// The SHA or branch name of the 's HEAD + string GetShaOrBranchNoLock(out string error, bool branch, bool tracked) + { + var result = LoadRepo(); + if (result != null) + { + error = result; + return null; + } + + try + { + error = null; + if (tracked && Repo.Head.TrackedBranch != null) + return Repo.Head.TrackedBranch.Tip.Sha; + return branch ? Repo.Head.FriendlyName : Repo.Head.Tip.Sha; + } + catch (Exception e) + { + error = e.ToString(); + return null; + } } ///