@@ -30,6 +30,13 @@ class HistoryView : Subview
3030 private const string ClearSelectionButton = "×" ;
3131 private const string NoRepoTitle = "No Git repository found for this project" ;
3232 private const string NoRepoDescription = "Initialize a Git repository to track changes and collaborate with others." ;
33+ private const string FetchActionTitle = "Fetch Changes" ;
34+ private const string FetchButtonText = "Fetch" ;
35+ private const string FetchFailureDescription = "Could not fetch changes" ;
36+ private const string FetchConfirmTitle = "Fetch Changes?" ;
37+ private const string FetchConfirmDescription = "Would you like to fetch changes from remote '{0}'?" ;
38+ private const string FetchConfirmYes = "Fetch" ;
39+ private const string FetchConfirmCancel = "Cancel" ;
3340 private const int HistoryExtraItemCount = 10 ;
3441 private const float MaxChangelistHeightRatio = .2f ;
3542
@@ -316,8 +323,14 @@ public void OnEmbeddedGUI()
316323
317324 GUILayout . FlexibleSpace ( ) ;
318325
326+ GUI . enabled = currentRemote != null ;
327+ var fetchClicked = GUILayout . Button ( FetchButtonText , Styles . HistoryToolbarButtonStyle ) ;
328+ GUI . enabled = true ;
329+ if ( fetchClicked )
330+ {
331+ Fetch ( ) ;
332+ }
319333
320- // Pull / Push buttons
321334 var pullButtonText = statusBehind > 0 ? String . Format ( PullButtonCount , statusBehind ) : PullButton ;
322335 GUI . enabled = currentRemote != null ;
323336 var pullClicked = GUILayout . Button ( pullButtonText , Styles . HistoryToolbarButtonStyle ) ;
@@ -733,6 +746,21 @@ private void Push()
733746 . Start ( ) ;
734747 }
735748
749+ private void Fetch ( )
750+ {
751+ var remote = Repository . CurrentRemote . HasValue ? Repository . CurrentRemote . Value . Name : String . Empty ;
752+ Repository
753+ . Fetch ( )
754+ . FinallyInUI ( ( success , e ) => {
755+ if ( ! success )
756+ {
757+ EditorUtility . DisplayDialog ( FetchActionTitle , FetchFailureDescription ,
758+ Localization . Ok ) ;
759+ }
760+ } )
761+ . Start ( ) ;
762+ }
763+
736764 void drawTimelineRectAroundIconRect ( Rect parentRect , Rect iconRect )
737765 {
738766 Color timelineBarColor = new Color ( 0.51F , 0.51F , 0.51F , 0.2F ) ;
0 commit comments