Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 26 additions & 40 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,7 @@ public override void OnDataUpdate()
{
base.OnDataUpdate();

string repoRemote = null;
if (MaybeUpdateData(out repoRemote))
{
repoBranchContent = new GUIContent(repoBranch, Window_RepoBranchTooltip);
if (repoUrl != null)
{
repoUrlContent = new GUIContent(repoUrl, string.Format(Window_RepoUrlTooltip, repoRemote));
}
else
{
repoUrlContent = new GUIContent(repoUrl, Window_RepoNoUrlTooltip);
}
}
MaybeUpdateData();

if (ActiveView != null)
ActiveView.OnDataUpdate();
Expand Down Expand Up @@ -198,45 +186,43 @@ private void RefreshOnMainThread()
new ActionTask(TaskManager.Token, Refresh) { Affinity = TaskAffinity.UI }.Start();
}

private bool MaybeUpdateData(out string repoRemote)
private void MaybeUpdateData()
{
repoRemote = null;
bool repoDataChanged = false;
string updatedRepoBranch = null;
string updatedRepoRemote = null;
string updatedRepoUrl = DefaultRepoUrl;

if (Repository != null)
{
var currentBranchString = (Repository.CurrentBranch.HasValue ? Repository.CurrentBranch.Value.Name : null);
if (repoBranch != currentBranchString)
{
repoBranch = currentBranchString;
repoDataChanged = true;
}
var repositoryCurrentBranch = Repository.CurrentBranch;
updatedRepoBranch = repositoryCurrentBranch.HasValue ? repositoryCurrentBranch.Value.Name : null;

var url = Repository.CloneUrl != null ? Repository.CloneUrl.ToString() : DefaultRepoUrl;
if (repoUrl != url)
{
repoUrl = url;
repoDataChanged = true;
}
var repositoryCloneUrl = Repository.CloneUrl;
updatedRepoUrl = repositoryCloneUrl != null ? repositoryCloneUrl.ToString() : DefaultRepoUrl;

if (Repository.CurrentRemote.HasValue)
repoRemote = Repository.CurrentRemote.Value.Name;
var repositoryCurrentRemote = Repository.CurrentRemote;
if (repositoryCurrentRemote.HasValue)
updatedRepoRemote = repositoryCurrentRemote.Value.Name;
}
else

if (repoBranch != updatedRepoBranch)
{
repoBranch = updatedRepoBranch;
repoBranchContent = new GUIContent(repoBranch, Window_RepoBranchTooltip);
}

if (repoUrl != updatedRepoUrl)
{
if (repoBranch != null)
repoUrl = updatedRepoUrl;
if (updatedRepoRemote != null)
{
repoBranch = null;
repoDataChanged = true;
repoUrlContent = new GUIContent(repoUrl, string.Format(Window_RepoUrlTooltip, updatedRepoRemote));
}

if (repoUrl != DefaultRepoUrl)
else
{
repoUrl = DefaultRepoUrl;
repoDataChanged = true;
repoUrlContent = new GUIContent(repoUrl, Window_RepoNoUrlTooltip);
}
}

return repoDataChanged;
}

private void AttachHandlers(IRepository repository)
Expand Down