sourcegit/src/Views/Popups/Reword.xaml.cs

41 lines
1.2 KiB
C#
Raw Normal View History

using System.Threading.Tasks;
using System.Windows.Controls;
namespace SourceGit.Views.Popups {
/// <summary>
/// 编辑HEAD的提交描述
/// </summary>
public partial class Reword : Controls.PopupWidget {
private string repo = null;
private string old = null;
public string Msg { get; set; }
public Reword(string repo, Models.Commit commit) {
this.repo = repo;
this.old = $"{commit.Subject}\n{commit.Message}".Trim();
this.Msg = old;
InitializeComponent();
txtCurrent.Text = $"{commit.ShortSHA} {commit.Subject}";
}
public override string GetTitle() {
return App.Text("Reword");
}
public override Task<bool> Start() {
txtMsg.GetBindingExpression(TextBox.TextProperty).UpdateSource();
if (Validation.GetHasError(txtMsg)) return null;
return Task.Run(() => {
if (old == Msg) return true;
Models.Watcher.SetEnabled(repo, false);
new Commands.Reword(repo, Msg).Exec();
Models.Watcher.SetEnabled(repo, true);
return true;
});
}
}
}