Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 6af8afd

Browse files
Restoring functionality to revert a commit
1 parent 6f4d529 commit 6af8afd

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/HistoryView.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,13 @@ public override void OnGUI()
459459
selectedEntry = entry;
460460
BuildTree();
461461
},
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+
});
464469

465470
if (requiresRepaint)
466471
Redraw();
@@ -546,6 +551,26 @@ private void HistoryDetailsEntry(GitLogEntry entry)
546551
GUILayout.EndVertical();
547552
}
548553

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+
549574
private void RepositoryTrackingOnStatusChanged(CacheUpdateEvent cacheUpdateEvent)
550575
{
551576
if (!lastAheadBehindChangedEvent.Equals(cacheUpdateEvent))

0 commit comments

Comments
 (0)