mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
feature: add save as path menu item for commit change (#724)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
22157a5c98
commit
8342702103
1 changed files with 28 additions and 0 deletions
|
@ -315,12 +315,40 @@ namespace SourceGit.ViewModels
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var patch = new MenuItem();
|
||||||
|
patch.Header = App.Text("FileCM.SaveAsPatch");
|
||||||
|
patch.Icon = App.CreateMenuIcon("Icons.Diff");
|
||||||
|
patch.Click += async (_, e) =>
|
||||||
|
{
|
||||||
|
var storageProvider = App.GetStorageProvider();
|
||||||
|
if (storageProvider == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var options = new FilePickerSaveOptions();
|
||||||
|
options.Title = App.Text("FileCM.SaveAsPatch");
|
||||||
|
options.DefaultExtension = ".patch";
|
||||||
|
options.FileTypeChoices = [new FilePickerFileType("Patch File") { Patterns = ["*.patch"] }];
|
||||||
|
|
||||||
|
var baseRevision = _commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : _commit.Parents[0];
|
||||||
|
var storageFile = await storageProvider.SaveFilePickerAsync(options);
|
||||||
|
if (storageFile != null)
|
||||||
|
{
|
||||||
|
var saveTo = storageFile.Path.LocalPath;
|
||||||
|
var succ = await Task.Run(() => Commands.SaveChangesAsPatch.ProcessRevisionCompareChanges(_repo.FullPath, [change], baseRevision, _commit.SHA, saveTo));
|
||||||
|
if (succ)
|
||||||
|
App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess"));
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
var menu = new ContextMenu();
|
var menu = new ContextMenu();
|
||||||
menu.Items.Add(diffWithMerger);
|
menu.Items.Add(diffWithMerger);
|
||||||
menu.Items.Add(explore);
|
menu.Items.Add(explore);
|
||||||
menu.Items.Add(new MenuItem { Header = "-" });
|
menu.Items.Add(new MenuItem { Header = "-" });
|
||||||
menu.Items.Add(history);
|
menu.Items.Add(history);
|
||||||
menu.Items.Add(blame);
|
menu.Items.Add(blame);
|
||||||
|
menu.Items.Add(patch);
|
||||||
menu.Items.Add(new MenuItem { Header = "-" });
|
menu.Items.Add(new MenuItem { Header = "-" });
|
||||||
|
|
||||||
var resetToThisRevision = new MenuItem();
|
var resetToThisRevision = new MenuItem();
|
||||||
|
|
Loading…
Reference in a new issue