mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-28 15:40:56 +01:00
Merge pull request #167 from Cyberboss/FurtherRevisionDerision
Revision command now shows the tracked remote commit if it exists
This commit is contained in:
@@ -58,16 +58,19 @@ namespace TGCommandLine
|
||||
if (!busy)
|
||||
{
|
||||
OutputProc("Repo: Idle");
|
||||
var head = Repo.GetHead(out string error);
|
||||
var head = Repo.GetHead(false, out string error);
|
||||
if (head == null)
|
||||
head = "Error: " + error;
|
||||
var remotehead = Repo.GetHead(true, out error);
|
||||
if (remotehead == null)
|
||||
remotehead = "Error: " + error;
|
||||
var branch = Repo.GetBranch(out error);
|
||||
if (branch == null)
|
||||
branch = "Error: " + error;
|
||||
var remote = Repo.GetRemote(out error);
|
||||
if (remote == null)
|
||||
remote = "Error: " + error;
|
||||
OutputProc("Remote: " + remote);
|
||||
OutputProc("Remote: " + remote + " (" + remotehead + ")");
|
||||
OutputProc("Branch: " + branch);
|
||||
OutputProc("HEAD: " + head);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace TGControlPanel
|
||||
RecloneButton.Visible = true;
|
||||
ResetRemote.Visible = true;
|
||||
|
||||
CurrentRevisionLabel.Text = Repo.GetHead(out string error) ?? "Unknown";
|
||||
CurrentRevisionLabel.Text = Repo.GetHead(false, out string error) ?? "Unknown";
|
||||
RepoRemoteTextBox.Text = Repo.GetRemote(out error) ?? "Unknown";
|
||||
RepoBranchTextBox.Text = Repo.GetBranch(out error) ?? "Unknown";
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace TGServerService
|
||||
}
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
OutputProc(String.Format("^{0}", Instance.GetHead(out string error)) ?? error);
|
||||
OutputProc(String.Format("^{0}", Instance.GetHead(true, out string error)) ?? error);
|
||||
return error == null ? ExitCode.Normal : ExitCode.ServerError;
|
||||
}
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace TGServerService
|
||||
}
|
||||
|
||||
//Gets what HEAD is pointing to
|
||||
string GetShaOrBranch(out string error, bool branch)
|
||||
string GetShaOrBranch(out string error, bool branch, bool tracked)
|
||||
{
|
||||
lock (RepoLock)
|
||||
{
|
||||
@@ -227,6 +227,8 @@ namespace TGServerService
|
||||
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)
|
||||
@@ -239,15 +241,15 @@ namespace TGServerService
|
||||
|
||||
//moist shleppy noises
|
||||
//public api
|
||||
public string GetHead(out string error)
|
||||
public string GetHead(bool useTracked, out string error)
|
||||
{
|
||||
return GetShaOrBranch(out error, false);
|
||||
return GetShaOrBranch(out error, false, useTracked);
|
||||
}
|
||||
|
||||
//public api
|
||||
public string GetBranch(out string error)
|
||||
{
|
||||
return GetShaOrBranch(out error, true);
|
||||
return GetShaOrBranch(out error, true, false);
|
||||
}
|
||||
|
||||
//public api
|
||||
|
||||
@@ -87,10 +87,11 @@ namespace TGServiceInterface
|
||||
/// <summary>
|
||||
/// Gets the sha of the current HEAD
|
||||
/// </summary>
|
||||
/// <param name="useTracked">If set to true and HEAD is currently a branch, will instead return the sha of the tracked remote branch if it exists</param>
|
||||
/// <param name="error">null on success, error message on failure</param>
|
||||
/// <returns>The sha of the current HEAD on success, null on failure</returns>
|
||||
[OperationContract]
|
||||
string GetHead(out string error);
|
||||
string GetHead(bool useTracked, out string error);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the current branch
|
||||
|
||||
Reference in New Issue
Block a user