Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit aa92bf0

Browse files
Cleaning up this logic
1 parent 9510e89 commit aa92bf0

File tree

1 file changed

+18
-31
lines changed
  • src/UnityExtension/Assets/Editor/GitHub.Unity/UI

1 file changed

+18
-31
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/Window.cs

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -188,48 +188,35 @@ private void RefreshOnMainThread()
188188

189189
private void MaybeUpdateData()
190190
{
191-
string repoRemote = null;
192-
var repoDataChanged = false;
191+
string updatedRepoBranch = null;
192+
string updatedRepoRemote = null;
193+
string updatedRepoUrl = DefaultRepoUrl;
194+
193195
if (Repository != null)
194196
{
195-
var currentBranchString = (Repository.CurrentBranch.HasValue ? Repository.CurrentBranch.Value.Name : null);
196-
if (repoBranch != currentBranchString)
197-
{
198-
repoBranch = currentBranchString;
199-
repoDataChanged = true;
200-
}
197+
var repositoryCurrentBranch = Repository.CurrentBranch;
198+
updatedRepoBranch = repositoryCurrentBranch.HasValue ? repositoryCurrentBranch.Value.Name : null;
201199

202-
var url = Repository.CloneUrl != null ? Repository.CloneUrl.ToString() : DefaultRepoUrl;
203-
if (repoUrl != url)
204-
{
205-
repoUrl = url;
206-
repoDataChanged = true;
207-
}
200+
var repositoryCloneUrl = Repository.CloneUrl;
201+
updatedRepoUrl = repositoryCloneUrl != null ? repositoryCloneUrl.ToString() : DefaultRepoUrl;
208202

209-
if (Repository.CurrentRemote.HasValue)
210-
repoRemote = Repository.CurrentRemote.Value.Name;
203+
var repositoryCurrentRemote = Repository.CurrentRemote;
204+
if (repositoryCurrentRemote.HasValue)
205+
updatedRepoRemote = repositoryCurrentRemote.Value.Name;
211206
}
212-
else
213-
{
214-
if (repoBranch != null)
215-
{
216-
repoBranch = null;
217-
repoDataChanged = true;
218-
}
219207

220-
if (repoUrl != DefaultRepoUrl)
221-
{
222-
repoUrl = DefaultRepoUrl;
223-
repoDataChanged = true;
224-
}
208+
if (repoBranch != updatedRepoBranch)
209+
{
210+
repoBranch = updatedRepoBranch;
211+
repoBranchContent = new GUIContent(repoBranch, Window_RepoBranchTooltip);
225212
}
226213

227-
if (repoDataChanged)
214+
if (repoUrl != updatedRepoUrl)
228215
{
229-
repoBranchContent = new GUIContent(repoBranch, Window_RepoBranchTooltip);
216+
repoUrl = updatedRepoUrl;
230217
if (repoUrl != null)
231218
{
232-
repoUrlContent = new GUIContent(repoUrl, string.Format(Window_RepoUrlTooltip, repoRemote));
219+
repoUrlContent = new GUIContent(repoUrl, string.Format(Window_RepoUrlTooltip, updatedRepoRemote));
233220
}
234221
else
235222
{

0 commit comments

Comments
 (0)