@@ -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
@@ -316,8 +323,14 @@ public void OnEmbeddedGUI()
316
323
317
324
GUILayout . FlexibleSpace ( ) ;
318
325
326
+ GUI . enabled = currentRemote != null ;
327
+ var fetchClicked = GUILayout . Button ( FetchButtonText , Styles . HistoryToolbarButtonStyle ) ;
328
+ GUI . enabled = true ;
329
+ if ( fetchClicked )
330
+ {
331
+ Fetch ( ) ;
332
+ }
319
333
320
- // Pull / Push buttons
321
334
var pullButtonText = statusBehind > 0 ? String . Format ( PullButtonCount , statusBehind ) : PullButton ;
322
335
GUI . enabled = currentRemote != null ;
323
336
var pullClicked = GUILayout . Button ( pullButtonText , Styles . HistoryToolbarButtonStyle ) ;
@@ -733,6 +746,21 @@ private void Push()
733
746
. Start ( ) ;
734
747
}
735
748
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
+
736
764
void drawTimelineRectAroundIconRect ( Rect parentRect , Rect iconRect )
737
765
{
738
766
Color timelineBarColor = new Color ( 0.51F , 0.51F , 0.51F , 0.2F ) ;
0 commit comments