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 +25
-2
lines changed
src/UnityExtension/Assets/Editor/GitHub.Unity/UI Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -459,8 +459,11 @@ 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
+ } ) ;
464
467
465
468
if ( requiresRepaint )
466
469
Redraw ( ) ;
@@ -546,6 +549,26 @@ private void HistoryDetailsEntry(GitLogEntry entry)
546
549
GUILayout . EndVertical ( ) ;
547
550
}
548
551
552
+ private void RevertCommit ( )
553
+ {
554
+ var dialogTitle = "Revert commit" ;
555
+ var dialogBody = string . Format ( @"Are you sure you want to revert the following commit:""{0}""" , selectedEntry . Summary ) ;
556
+
557
+ if ( EditorUtility . DisplayDialog ( dialogTitle , dialogBody , "Revert" , "Cancel" ) )
558
+ {
559
+ Repository
560
+ . Revert ( selectedEntry . CommitID )
561
+ . FinallyInUI ( ( success , e ) => {
562
+ if ( ! success )
563
+ {
564
+ EditorUtility . DisplayDialog ( dialogTitle ,
565
+ "Error reverting commit: " + e . Message , Localization . Cancel ) ;
566
+ }
567
+ } )
568
+ . Start ( ) ;
569
+ }
570
+ }
571
+
549
572
private void RepositoryTrackingOnStatusChanged ( CacheUpdateEvent cacheUpdateEvent )
550
573
{
551
574
if ( ! lastAheadBehindChangedEvent . Equals ( cacheUpdateEvent ) )
You can’t perform that action at this time.
0 commit comments