2020-07-03 00:24:31 -07:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Windows;
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
|
namespace SourceGit.UI {
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// `git init` confirm panel.
|
|
|
|
/// </summary>
|
|
|
|
public partial class Init : UserControl {
|
2020-08-06 00:41:25 -07:00
|
|
|
private PopupManager popup = null;
|
2020-07-03 00:24:31 -07:00
|
|
|
private string workingDir = null;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Constructor.
|
|
|
|
/// </summary>
|
2020-08-06 00:41:25 -07:00
|
|
|
/// <param name="mgr"></param>
|
2020-07-03 00:24:31 -07:00
|
|
|
/// <param name="path"></param>
|
2020-08-06 00:41:25 -07:00
|
|
|
public Init(PopupManager mgr, string path) {
|
|
|
|
popup = mgr;
|
2020-07-03 00:24:31 -07:00
|
|
|
workingDir = path;
|
|
|
|
InitializeComponent();
|
|
|
|
txtPath.Content = path;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Do `git init`
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private async void Sure(object sender, RoutedEventArgs e) {
|
2020-08-03 01:23:00 -07:00
|
|
|
popup.Lock();
|
2020-07-03 00:24:31 -07:00
|
|
|
|
|
|
|
await Task.Run(() => {
|
|
|
|
var errs = Git.Repository.RunCommand(workingDir, "init -q", null);
|
|
|
|
if (errs != null) {
|
|
|
|
App.RaiseError(errs);
|
|
|
|
} else {
|
|
|
|
App.Preference.AddRepository(workingDir, "");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-08-03 01:23:00 -07:00
|
|
|
popup.Close(true);
|
2020-07-03 00:24:31 -07:00
|
|
|
|
|
|
|
var repo = App.Preference.FindRepository(workingDir);
|
|
|
|
if (repo != null) repo.Open();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Cancel.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private void Cancel(object sender, RoutedEventArgs e) {
|
2020-08-06 00:41:25 -07:00
|
|
|
popup.Close();
|
2020-07-03 00:24:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|