@@ -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
@@ -321,8 +328,19 @@ public void OnEmbeddedGUI()
321328
322329 GUILayout . FlexibleSpace ( ) ;
323330
331+ GUI . enabled = currentRemote != null ;
332+ var fetchClicked = GUILayout . Button ( FetchButtonText , Styles . HistoryToolbarButtonStyle ) ;
333+ GUI . enabled = true ;
334+ if ( fetchClicked &&
335+ EditorUtility . DisplayDialog ( FetchConfirmTitle ,
336+ String . Format ( FetchConfirmDescription , currentRemote ) ,
337+ FetchConfirmYes ,
338+ FetchConfirmCancel )
339+ )
340+ {
341+ Fetch ( ) ;
342+ }
324343
325- // Pull / Push buttons
326344 var pullButtonText = statusBehind > 0 ? String . Format ( PullButtonCount , statusBehind ) : PullButton ;
327345 GUI . enabled = currentRemote != null ;
328346 var pullClicked = GUILayout . Button ( pullButtonText , Styles . HistoryToolbarButtonStyle ) ;
@@ -708,6 +726,21 @@ private void Push()
708726 . Start ( ) ;
709727 }
710728
729+ private void Fetch ( )
730+ {
731+ var remote = Repository . CurrentRemote . HasValue ? Repository . CurrentRemote . Value . Name : String . Empty ;
732+ Repository
733+ . Fetch ( )
734+ . FinallyInUI ( ( success , e ) => {
735+ if ( ! success )
736+ {
737+ EditorUtility . DisplayDialog ( FetchActionTitle , FetchFailureDescription ,
738+ Localization . Cancel ) ;
739+ }
740+ } )
741+ . Start ( ) ;
742+ }
743+
711744 void drawTimelineRectAroundIconRect ( Rect parentRect , Rect iconRect )
712745 {
713746 Color timelineBarColor = new Color ( 0.51F , 0.51F , 0.51F , 0.2F ) ;
0 commit comments