using System.Threading.Tasks; using System.Windows.Controls; namespace SourceGit.Views.Popups { /// /// 编辑HEAD的提交描述 /// 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 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; }); } } }