From 494aa41f2e0aac4738ebe43d66531c3c39e058b7 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Wed, 13 Sep 2017 10:34:34 -0400 Subject: [PATCH] Revision command now shows the tracked remote commit if it exists --- TGCommandLine/RepoCommands.cs | 7 +++++-- TGControlPanel/RepoPage.cs | 2 +- TGServerService/ChatCommands.cs | 2 +- TGServerService/Repository.cs | 10 ++++++---- TGServiceInterface/Repository.cs | 3 ++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/TGCommandLine/RepoCommands.cs b/TGCommandLine/RepoCommands.cs index 32c8cf5825..e6b727d02f 100644 --- a/TGCommandLine/RepoCommands.cs +++ b/TGCommandLine/RepoCommands.cs @@ -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); } diff --git a/TGControlPanel/RepoPage.cs b/TGControlPanel/RepoPage.cs index f0e8822e93..b24935ab0e 100644 --- a/TGControlPanel/RepoPage.cs +++ b/TGControlPanel/RepoPage.cs @@ -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"; diff --git a/TGServerService/ChatCommands.cs b/TGServerService/ChatCommands.cs index 05bbd39394..2e2ec6dab6 100644 --- a/TGServerService/ChatCommands.cs +++ b/TGServerService/ChatCommands.cs @@ -82,7 +82,7 @@ namespace TGServerService } protected override ExitCode Run(IList 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; } diff --git a/TGServerService/Repository.cs b/TGServerService/Repository.cs index 3f7d730435..6c32b3f66e 100644 --- a/TGServerService/Repository.cs +++ b/TGServerService/Repository.cs @@ -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 diff --git a/TGServiceInterface/Repository.cs b/TGServiceInterface/Repository.cs index 2e37dfc627..82f39ee2e1 100644 --- a/TGServiceInterface/Repository.cs +++ b/TGServiceInterface/Repository.cs @@ -87,10 +87,11 @@ namespace TGServiceInterface /// /// Gets the sha of the current HEAD /// + /// If set to true and HEAD is currently a branch, will instead return the sha of the tracked remote branch if it exists /// null on success, error message on failure /// The sha of the current HEAD on success, null on failure [OperationContract] - string GetHead(out string error); + string GetHead(bool useTracked, out string error); /// /// Gets the name of the current branch