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.Content = $"{commit.ShortSHA} {commit.Subject}";
}
///
/// Open this dialog.
///
///
///
public static void Show(Git.Repository repo, Git.Commit commit) {
PopupManager.Show(new Revert(repo, commit));
}
///
/// Start revert.
///
///
///
private async void Sure(object sender, RoutedEventArgs e) {
bool autoCommit = chkCommit.IsChecked == true;
PopupManager.Lock();
await Task.Run(() => repo.Revert(sha, autoCommit));
PopupManager.Close(true);
}
///
/// Cancel.
///
///
///
private void Cancel(object sender, RoutedEventArgs e) {
PopupManager.Close();
}
}
}