Merge pull request #149 from Cyberboss/SubmoduleMastery

Adds submodule update handling
This commit is contained in:
Jordan Brown
2017-09-06 16:30:09 -04:00
committed by GitHub
2 changed files with 44 additions and 1 deletions
+43 -1
View File
@@ -318,6 +318,7 @@ namespace TGServerService
};
Commands.Checkout(Repo, sha, Opts);
var res = ResetNoLock(null);
UpdateSubmodules();
SendMessage("REPO: Checkout complete!", ChatMessageType.DeveloperInfo);
TGServerService.WriteInfo("Repo checked out " + sha, TGServerService.EventID.RepoCheckout);
return res;
@@ -375,11 +376,12 @@ namespace TGServerService
};
fos.OnTransferProgress += HandleTransferProgress;
Commands.Fetch(Repo, R.Name, refSpecs, fos, logMessage);
var originBranch = Repo.Head.TrackedBranch;
if (reset)
{
var error = ResetNoLock(Repo.Head.TrackedBranch);
UpdateSubmodules();
if (error != null)
throw new Exception(error);
DeletePRList();
@@ -389,6 +391,7 @@ namespace TGServerService
var res = MergeBranch(originBranch.FriendlyName);
if (res != null)
throw new Exception(res);
UpdateSubmodules();
TGServerService.WriteInfo("Repo merge updated to " + originBranch.Tip.Sha, TGServerService.EventID.RepoMergeUpdate);
return null;
}
@@ -401,6 +404,35 @@ namespace TGServerService
}
}
private void UpdateSubmodules()
{
var suo = new SubmoduleUpdateOptions
{
Init = true
};
foreach (var I in Repo.Submodules)
try
{
Repo.Submodules.Update(I.Name, suo);
}
catch(Exception e)
{
//workaround for https://github.com/libgit2/libgit2/issues/3820
//kill off the modules/ folder in .git and try again
try
{
Program.DeleteDirectory(String.Format("{0}/.git/modules/{1}", RepoPath, I.Path));
}
catch {
throw e;
}
Repo.Submodules.Update(I.Name, suo);
var msg = String.Format("I had to reclone submodule {0}. If this is happening a lot find a better hack or fix https://github.com/libgit2/libgit2/issues/3820!", I.Name);
SendMessage(String.Format("REPO: {0}", msg), ChatMessageType.DeveloperInfo);
TGServerService.WriteWarning(msg, TGServerService.EventID.SubmoduleReclone);
}
}
string CreateBackup()
{
try
@@ -568,6 +600,16 @@ namespace TGServerService
//so we'll know if this fails
var Result = MergeBranch(LocalBranchName);
if (Result == null)
try
{
UpdateSubmodules();
}
catch (Exception e)
{
Result = e.ToString();
}
if (Result == null)
{
TGServerService.WriteInfo(String.Format("Merged pull request #{0}", PRNumber), TGServerService.EventID.RepoPRMerge);
+1
View File
@@ -75,6 +75,7 @@ namespace TGServerService
ServerUpdateApplied = 6300,
ChatBroadcastFail = 6400,
IRCLogModes = 6500,
SubmoduleReclone = 6600,
}
static TGServerService ActiveService; //So everyone else can write to our eventlog