This repository was archived by the owner on Dec 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
src/UnityExtension/Assets/Editor/GitHub.Unity/UI Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -459,8 +459,13 @@ public override void OnGUI()
459
459
selectedEntry = entry ;
460
460
BuildTree ( ) ;
461
461
} ,
462
- entry => { } ,
463
- entry => { } ) ;
462
+ entry => { } , entry => {
463
+ GenericMenu menu = new GenericMenu ( ) ;
464
+ menu . AddItem ( new GUIContent ( "Revert" ) , false , RevertCommit ) ;
465
+ menu . ShowAsContext ( ) ;
466
+
467
+ Event . current . Use ( ) ;
468
+ } ) ;
464
469
465
470
if ( requiresRepaint )
466
471
Redraw ( ) ;
@@ -546,6 +551,26 @@ private void HistoryDetailsEntry(GitLogEntry entry)
546
551
GUILayout . EndVertical ( ) ;
547
552
}
548
553
554
+ private void RevertCommit ( )
555
+ {
556
+ var dialogTitle = "Revert commit" ;
557
+ var dialogBody = string . Format ( @"Are you sure you want to revert the following commit:""{0}""" , selectedEntry . Summary ) ;
558
+
559
+ if ( EditorUtility . DisplayDialog ( dialogTitle , dialogBody , "Revert" , "Cancel" ) )
560
+ {
561
+ Repository
562
+ . Revert ( selectedEntry . CommitID )
563
+ . FinallyInUI ( ( success , e ) => {
564
+ if ( ! success )
565
+ {
566
+ EditorUtility . DisplayDialog ( dialogTitle ,
567
+ "Error reverting commit: " + e . Message , Localization . Cancel ) ;
568
+ }
569
+ } )
570
+ . Start ( ) ;
571
+ }
572
+ }
573
+
549
574
private void RepositoryTrackingOnStatusChanged ( CacheUpdateEvent cacheUpdateEvent )
550
575
{
551
576
if ( ! lastAheadBehindChangedEvent . Equals ( cacheUpdateEvent ) )
You can’t perform that action at this time.
0 commit comments