2020-07-20 22:35:59 -07:00
|
|
|
using System.Windows;
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
|
|
|
namespace SourceGit.UI {
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Repository configuration dialog
|
|
|
|
/// </summary>
|
|
|
|
public partial class Configure : UserControl {
|
|
|
|
private Git.Repository repo = null;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// User name for this repository.
|
|
|
|
/// </summary>
|
|
|
|
public string UserName { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// User email for this repository.
|
|
|
|
/// </summary>
|
|
|
|
public string UserEmail { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Commit template for this repository.
|
|
|
|
/// </summary>
|
|
|
|
public string CommitTemplate { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Constructor.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="repo"></param>
|
|
|
|
public Configure(Git.Repository repo) {
|
|
|
|
this.repo = repo;
|
|
|
|
|
2020-07-21 20:39:05 -07:00
|
|
|
UserName = repo.GetConfig("user.name");
|
|
|
|
UserEmail = repo.GetConfig("user.email");
|
2020-07-20 22:35:59 -07:00
|
|
|
CommitTemplate = repo.CommitTemplate;
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Show this dialog.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="repo"></param>
|
|
|
|
public static void Show(Git.Repository repo) {
|
2020-08-06 00:41:25 -07:00
|
|
|
repo.GetPopupManager()?.Show(new Configure(repo));
|
2020-07-20 22:35:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#region EVENTS
|
|
|
|
private void Save(object sender, RoutedEventArgs e) {
|
2020-07-21 20:39:05 -07:00
|
|
|
var oldUser = repo.GetConfig("user.name");
|
|
|
|
if (oldUser != UserName) repo.SetConfig("user.name", UserName);
|
2020-07-20 22:35:59 -07:00
|
|
|
|
2020-07-21 20:39:05 -07:00
|
|
|
var oldEmail = repo.GetConfig("user.email");
|
|
|
|
if (oldEmail != UserEmail) repo.SetConfig("user.email", UserEmail);
|
2020-07-20 22:35:59 -07:00
|
|
|
|
|
|
|
if (CommitTemplate != repo.CommitTemplate) {
|
|
|
|
repo.CommitTemplate = CommitTemplate;
|
2020-12-16 19:55:06 -08:00
|
|
|
App.SaveSetting();
|
2020-07-20 22:35:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Close(sender, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Close(object sender, RoutedEventArgs e) {
|
2020-08-06 00:41:25 -07:00
|
|
|
repo.GetPopupManager()?.Close();
|
2020-07-20 22:35:59 -07:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|