fix: running git command in UIThread via context menu entry blocks whole app (#1384)
Some checks failed
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions
Localization Check / localization-check (push) Has been cancelled

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-06-03 23:36:15 +08:00
parent d85f82e171
commit c2187edbe9
No known key found for this signature in database
4 changed files with 37 additions and 24 deletions

View file

@ -234,10 +234,28 @@ namespace SourceGit.ViewModels
var resetToThisRevision = new MenuItem();
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
resetToThisRevision.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToThisRevision.Click += (_, ev) =>
resetToThisRevision.Click += async (_, ev) =>
{
var log = _repo.CreateLog($"Reset File to '{_selectedStash.SHA}'");
new Commands.Checkout(_repo.FullPath).Use(log).FileWithRevision(change.Path, $"{_selectedStash.SHA}");
await Task.Run(() =>
{
if (_untracked.Contains(change))
{
Commands.SaveRevisionFile.Run(_repo.FullPath, _selectedStash.Parents[2], change.Path, fullPath);
}
else if (change.Index == Models.ChangeState.Added)
{
Commands.SaveRevisionFile.Run(_repo.FullPath, _selectedStash.SHA, change.Path, fullPath);
}
else
{
new Commands.Checkout(_repo.FullPath)
.Use(log)
.FileWithRevision(change.Path, $"{_selectedStash.SHA}");
}
});
log.Complete();
ev.Handled = true;
};