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

Commit

Permalink
Merge pull request #74 from github-for-unity/features/git-fetch-button
Browse files Browse the repository at this point in the history
Adding git fetch button
  • Loading branch information
StanleyGoldman authored Jul 5, 2017
2 parents e659480 + d380ace commit 8629a70
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/GitHub.Api/Git/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface IRepository : IEquatable<IRepository>
ITask SetupRemote(string remoteName, string remoteUrl);
ITask Pull();
ITask Push();
ITask Fetch();
ITask Revert(string changeset);
ITask ListLocks();
ITask RequestLock(string file);
Expand Down
5 changes: 5 additions & 0 deletions src/GitHub.Api/Git/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public ITask Push()
return repositoryManager.Push(CurrentRemote.Value.Name, CurrentBranch);
}

public ITask Fetch()
{
return repositoryManager.Fetch(CurrentRemote.Value.Name);
}

public ITask Revert(string changeset)
{
return repositoryManager.Revert(changeset);
Expand Down
30 changes: 29 additions & 1 deletion src/UnityExtension/Assets/Editor/GitHub.Unity/UI/HistoryView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ class HistoryView : Subview
private const string ClearSelectionButton = "×";
private const string NoRepoTitle = "No Git repository found for this project";
private const string NoRepoDescription = "Initialize a Git repository to track changes and collaborate with others.";
private const string FetchActionTitle = "Fetch Changes";
private const string FetchButtonText = "Fetch";
private const string FetchFailureDescription = "Could not fetch changes";
private const string FetchConfirmTitle = "Fetch Changes?";
private const string FetchConfirmDescription = "Would you like to fetch changes from remote '{0}'?";
private const string FetchConfirmYes = "Fetch";
private const string FetchConfirmCancel = "Cancel";
private const int HistoryExtraItemCount = 10;
private const float MaxChangelistHeightRatio = .2f;

Expand Down Expand Up @@ -316,8 +323,14 @@ public void OnEmbeddedGUI()

GUILayout.FlexibleSpace();

GUI.enabled = currentRemote != null;
var fetchClicked = GUILayout.Button(FetchButtonText, Styles.HistoryToolbarButtonStyle);
GUI.enabled = true;
if (fetchClicked)
{
Fetch();
}

// Pull / Push buttons
var pullButtonText = statusBehind > 0 ? String.Format(PullButtonCount, statusBehind) : PullButton;
GUI.enabled = currentRemote != null;
var pullClicked = GUILayout.Button(pullButtonText, Styles.HistoryToolbarButtonStyle);
Expand Down Expand Up @@ -733,6 +746,21 @@ private void Push()
.Start();
}

private void Fetch()
{
var remote = Repository.CurrentRemote.HasValue ? Repository.CurrentRemote.Value.Name : String.Empty;
Repository
.Fetch()
.FinallyInUI((success, e) => {
if (!success)
{
EditorUtility.DisplayDialog(FetchActionTitle, FetchFailureDescription,
Localization.Ok);
}
})
.Start();
}

void drawTimelineRectAroundIconRect(Rect parentRect, Rect iconRect)
{
Color timelineBarColor = new Color(0.51F, 0.51F, 0.51F, 0.2F);
Expand Down

0 comments on commit 8629a70

Please sign in to comment.