Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
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
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