using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace SourceGit.UI {
///
/// Confirm to revert selected commit.
///
public partial class Revert : UserControl {
private Git.Repository repo = null;
private string sha = null;
///
/// Constructor.
///
/// Opened repository
/// Commit to be reverted
public Revert(Git.Repository opened, Git.Commit commit) {
repo = opened;
sha = commit.SHA;
InitializeComponent();
txtDesc.Text = $"{commit.ShortSHA} {commit.Subject}";
}
///
/// Open this dialog.
///
///
///
public static void Show(Git.Repository repo, Git.Commit commit) {
repo.GetPopupManager()?.Show(new Revert(repo, commit));
}
///
/// Start revert.
///
///
///
private async void Sure(object sender, RoutedEventArgs e) {
bool autoCommit = chkCommit.IsChecked == true;
var popup = repo.GetPopupManager();
popup?.Lock();
await Task.Run(() => repo.Revert(sha, autoCommit));
popup?.Close(true);
}
///
/// Cancel.
///
///
///
private void Cancel(object sender, RoutedEventArgs e) {
repo.GetPopupManager()?.Close();
}
}
}