diff --git a/src/Git/Repository.cs b/src/Git/Repository.cs
index 7423d405..bbbf5133 100644
--- a/src/Git/Repository.cs
+++ b/src/Git/Repository.cs
@@ -974,6 +974,27 @@ namespace SourceGit.Git {
isWatcherDisabled = false;
}
+ ///
+ /// Delete submodule
+ ///
+ ///
+ public void DeleteSubmodule(string path) {
+ isWatcherDisabled = true;
+
+ var errs = RunCommand($"submodule deinit -f {path}", null);
+ if (errs != null) {
+ App.RaiseError(errs);
+ } else {
+ errs = RunCommand($"rm -f {path}", null);
+ if (errs != null) App.RaiseError(errs);
+
+ OnWorkingCopyChanged?.Invoke();
+ OnSubmoduleChanged?.Invoke();
+ }
+
+ isWatcherDisabled = false;
+ }
+
///
/// Blame file.
///
diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml
index 763e5d49..cdd06432 100644
--- a/src/Resources/Locales/en_US.xaml
+++ b/src/Resources/Locales/en_US.xaml
@@ -50,6 +50,7 @@
Fetch nested submodules
Open Submodule Repository
Copy Relative Path
+ Delete Submodule
Cherry-Pick This Commit
Cherry Pick
@@ -215,6 +216,9 @@
Tag :
Delete from remote repositories
+ Confirm To Delete Submodule
+ Submodule Path :
+
Next Difference
Previous Difference
Toggle One-Side/Two-Sides
diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml
index dbe1bc3e..54eab305 100644
--- a/src/Resources/Locales/zh_CN.xaml
+++ b/src/Resources/Locales/zh_CN.xaml
@@ -50,6 +50,7 @@
拉取子孙模块
打开仓库
复制路径
+ 删除子模块
挑选此提交
挑选提交
@@ -214,6 +215,9 @@
确定要移除该标签吗?
标签名 :
同时删除远程仓库中的此标签
+
+ 确定要移除该子模块吗?
+ 子模块路径 :
下一个差异
上一个差异
diff --git a/src/UI/Dashboard.xaml.cs b/src/UI/Dashboard.xaml.cs
index 7c3b79cd..2cdd4a2c 100644
--- a/src/UI/Dashboard.xaml.cs
+++ b/src/UI/Dashboard.xaml.cs
@@ -1026,9 +1026,17 @@ namespace SourceGit.UI {
ev.Handled = true;
};
+ var rm = new MenuItem();
+ rm.Header = App.Text("Submodule.Remove");
+ rm.Click += (o, ev) => {
+ DeleteSubmodule.Show(repo, path);
+ ev.Handled = true;
+ };
+
var menu = new ContextMenu();
menu.Items.Add(open);
menu.Items.Add(copy);
+ menu.Items.Add(rm);
menu.IsOpen = true;
e.Handled = true;
diff --git a/src/UI/DeleteSubmodule.xaml b/src/UI/DeleteSubmodule.xaml
new file mode 100644
index 00000000..cd62f2a5
--- /dev/null
+++ b/src/UI/DeleteSubmodule.xaml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/UI/DeleteSubmodule.xaml.cs b/src/UI/DeleteSubmodule.xaml.cs
new file mode 100644
index 00000000..3492dbe0
--- /dev/null
+++ b/src/UI/DeleteSubmodule.xaml.cs
@@ -0,0 +1,36 @@
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace SourceGit.UI {
+
+ ///
+ /// Interaction logic for DeleteSubmodule.xaml
+ ///
+ public partial class DeleteSubmodule : UserControl {
+ private Git.Repository repo = null;
+ private string submodule = null;
+
+ public DeleteSubmodule(Git.Repository opened, string path) {
+ InitializeComponent();
+ repo = opened;
+ submodule = path;
+ targetPath.Text = path;
+ }
+
+ public static void Show(Git.Repository repo, string submodule) {
+ repo.GetPopupManager()?.Show(new DeleteSubmodule(repo, submodule));
+ }
+
+ private async void Sure(object sender, RoutedEventArgs e) {
+ var popup = repo.GetPopupManager();
+ popup?.Lock();
+ await Task.Run(() => repo.DeleteSubmodule(submodule));
+ popup?.Close(true);
+ }
+
+ private void Cancel(object sender, RoutedEventArgs e) {
+ repo.GetPopupManager()?.Close();
+ }
+ }
+}