@@ -30,6 +30,13 @@ class HistoryView : Subview
30
30
private const string ClearSelectionButton = "×" ;
31
31
private const string NoRepoTitle = "No Git repository found for this project" ;
32
32
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" ;
33
40
private const int HistoryExtraItemCount = 10 ;
34
41
private const float MaxChangelistHeightRatio = .2f ;
35
42
@@ -321,8 +328,19 @@ public void OnEmbeddedGUI()
321
328
322
329
GUILayout . FlexibleSpace ( ) ;
323
330
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
+ }
324
343
325
- // Pull / Push buttons
326
344
var pullButtonText = statusBehind > 0 ? String . Format ( PullButtonCount , statusBehind ) : PullButton ;
327
345
GUI . enabled = currentRemote != null ;
328
346
var pullClicked = GUILayout . Button ( pullButtonText , Styles . HistoryToolbarButtonStyle ) ;
@@ -708,6 +726,21 @@ private void Push()
708
726
. Start ( ) ;
709
727
}
710
728
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
+
711
744
void drawTimelineRectAroundIconRect ( Rect parentRect , Rect iconRect )
712
745
{
713
746
Color timelineBarColor = new Color ( 0.51F , 0.51F , 0.51F , 0.2F ) ;
0 commit comments