diff --git a/src/Commands/Submodule.cs b/src/Commands/Submodule.cs index 20cc845c..025d035a 100644 --- a/src/Commands/Submodule.cs +++ b/src/Commands/Submodule.cs @@ -51,13 +51,15 @@ namespace SourceGit.Commands return Exec(); } - public bool Delete(string relativePath) + public bool Deinit(string module, bool force) { - Args = $"submodule deinit -f \"{relativePath}\""; - if (!Exec()) - return false; + Args = force ? $"submodule deinit -f -- \"{module}\"" : $"submodule deinit -- \"{module}\""; + return Exec(); + } - Args = $"rm -rf \"{relativePath}\""; + public bool Delete(string module) + { + Args = $"rm -rf \"{module}\""; return Exec(); } } diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index a1b0578b..885e8212 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -231,6 +231,9 @@ lightweight Hold Ctrl to start directly Cut + De-initialize Submodule + Force de-init event if it contains local changes. + Submodule: Delete Branch Branch: You are about to delete a remote branch!!! @@ -266,6 +269,7 @@ Show hidden symbols Side-By-Side Diff SUBMODULE + DELETED NEW Swap Syntax Highlighting @@ -708,6 +712,7 @@ SUBMODULES Add Submodule Copy Relative Path + De-initialize Submodule Fetch nested submodules Open Submodule Repository Relative Path: diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index d42b2344..627c7725 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -235,6 +235,9 @@ 轻量标签 按住Ctrl键点击将以默认参数运行 剪切 + 取消初始化子模块 + 强制取消,即使包含本地变更 + 子模块 : 删除分支确认 分支名 : 您正在删除远程上的分支,请务必小心!!! @@ -270,6 +273,7 @@ 显示隐藏符号 分列对比 子模块 + 删除 新增 交换比对双方 语法高亮 @@ -712,6 +716,7 @@ 子模块 添加子模块 复制路径 + 取消初始化 拉取子孙模块 打开仓库 相对仓库路径 : diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index b89a44c6..065ac49d 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -235,6 +235,9 @@ 輕量標籤 按住 Ctrl 鍵將直接以預設參數執行 剪下 + 取消初始化子模組 + 強制取消,即使它包含本地變更 + 子模組 : 刪除分支確認 分支名稱: 您正在刪除遠端上的分支,請務必小心! @@ -270,6 +273,7 @@ 顯示隱藏符號 並排對比 子模組 + 已刪除 新增 交換比對雙方 語法上色 @@ -712,6 +716,7 @@ 子模組 新增子模組 複製路徑 + 取消初始化 提取子模組 開啟存放庫 相對存放庫路徑: diff --git a/src/ViewModels/DeinitSubmodule.cs b/src/ViewModels/DeinitSubmodule.cs new file mode 100644 index 00000000..a96a65d0 --- /dev/null +++ b/src/ViewModels/DeinitSubmodule.cs @@ -0,0 +1,45 @@ +using System.Threading.Tasks; + +namespace SourceGit.ViewModels +{ + public class DeinitSubmodule : Popup + { + public string Submodule + { + get; + private set; + } + + public bool Force + { + get; + set; + } + + public DeinitSubmodule(Repository repo, string submodule) + { + _repo = repo; + Submodule = submodule; + Force = false; + } + + public override Task Sure() + { + _repo.SetWatcherEnabled(false); + ProgressDescription = "De-initialize Submodule"; + + var log = _repo.CreateLog("De-initialize Submodule"); + Use(log); + + return Task.Run(() => + { + var succ = new Commands.Submodule(_repo.FullPath).Use(log).Deinit(Submodule, false); + log.Complete(); + CallUIThread(() => _repo.SetWatcherEnabled(true)); + return succ; + }); + } + + private Repository _repo; + } +} diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index da166557..5c2986fa 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -2432,12 +2432,14 @@ namespace SourceGit.ViewModels ev.Handled = true; }; - var copy = new MenuItem(); - copy.Header = App.Text("Submodule.CopyPath"); - copy.Icon = App.CreateMenuIcon("Icons.Copy"); - copy.Click += (_, ev) => + var deinit = new MenuItem(); + deinit.Header = App.Text("Submodule.Deinit"); + deinit.Icon = App.CreateMenuIcon("Icons.Undo"); + deinit.IsEnabled = submodule.Status != Models.SubmoduleStatus.NotInited; + deinit.Click += (_, ev) => { - App.CopyText(submodule.Path); + if (CanCreatePopup()) + ShowPopup(new DeinitSubmodule(this, submodule.Path)); ev.Handled = true; }; @@ -2451,10 +2453,22 @@ namespace SourceGit.ViewModels ev.Handled = true; }; + var copy = new MenuItem(); + copy.Header = App.Text("Submodule.CopyPath"); + copy.Icon = App.CreateMenuIcon("Icons.Copy"); + copy.Click += (_, ev) => + { + App.CopyText(submodule.Path); + ev.Handled = true; + }; + var menu = new ContextMenu(); menu.Items.Add(open); - menu.Items.Add(copy); + menu.Items.Add(new MenuItem() { Header = "-" }); + menu.Items.Add(deinit); menu.Items.Add(rm); + menu.Items.Add(new MenuItem() { Header = "-" }); + menu.Items.Add(copy); return menu; } diff --git a/src/Views/DeinitSubmodule.axaml b/src/Views/DeinitSubmodule.axaml new file mode 100644 index 00000000..d3e0b641 --- /dev/null +++ b/src/Views/DeinitSubmodule.axaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/src/Views/DeinitSubmodule.axaml.cs b/src/Views/DeinitSubmodule.axaml.cs new file mode 100644 index 00000000..18dd9944 --- /dev/null +++ b/src/Views/DeinitSubmodule.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace SourceGit.Views +{ + public partial class DeinitSubmodule : UserControl + { + public DeinitSubmodule() + { + InitializeComponent(); + } + } +} diff --git a/src/Views/DiffView.axaml b/src/Views/DiffView.axaml index 5bed2893..85da69d1 100644 --- a/src/Views/DiffView.axaml +++ b/src/Views/DiffView.axaml @@ -279,8 +279,18 @@ - - + + + + + + + + + + + +