diff --git a/src/Commands/Submodule.cs b/src/Commands/Submodule.cs index 3c4460ea..9a273703 100644 --- a/src/Commands/Submodule.cs +++ b/src/Commands/Submodule.cs @@ -13,36 +13,46 @@ namespace SourceGit.Commands public bool Add(string url, string relativePath, bool recursive, Action outputHandler) { _outputHandler = outputHandler; - Args = $"submodule add {url} {relativePath}"; + Args = $"submodule add {url} \"{relativePath}\""; if (!Exec()) return false; if (recursive) { - Args = $"submodule update --init --recursive -- {relativePath}"; + Args = $"submodule update --init --recursive -- \"{relativePath}\""; return Exec(); } else { - Args = $"submodule update --init -- {relativePath}"; + Args = $"submodule update --init -- \"{relativePath}\""; return true; } } - public bool Update(Action outputHandler) + public bool Update(string module, bool init, bool recursive, bool useRemote, Action outputHandler) { - Args = $"submodule update --rebase --remote"; + Args = "submodule update"; + + if (init) + Args += " --init"; + if (recursive) + Args += " --recursive"; + if (useRemote) + Args += " --remote"; + if (!string.IsNullOrEmpty(module)) + Args += $" -- \"{module}\""; + _outputHandler = outputHandler; return Exec(); } public bool Delete(string relativePath) { - Args = $"submodule deinit -f {relativePath}"; + Args = $"submodule deinit -f \"{relativePath}\""; if (!Exec()) return false; - Args = $"rm -rf {relativePath}"; + Args = $"rm -rf \"{relativePath}\""; return Exec(); } diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index e1220d5f..cc09d42f 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -545,7 +545,11 @@ Push ${0}$... URL: Update Submodules - Run `submodule update` command for this repository. + All submodules + Initialize as needed + Recursively + Submodule: + Use --remote option Warning Create Group Create Sub-Group diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 1b0a0d46..ab8f79f7 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -547,7 +547,11 @@ 推送 ${0}$... 仓库地址 : 更新子模块 - 为此仓库执行`submodule update`命令,更新所有的子模块。 + 更新所有子模块 + 启用 '--init' + 启用 '--recursive' + 子模块 : + 启用 '--remote' 警告 新建分组 新建子分组 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index d75ad3f2..ac1acfee 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -547,7 +547,11 @@ 推送 ${0}$... 倉庫地址 : 更新子模組 - 本操作將執行 `submodule update` 。 + 更新所有子模組 + 啟用『--init』選項 + 啟用『--recursive』選項 + 子模組 : + 啟用『--remote』選項 警告 新建分組 新建子分組 diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index a7faeb35..16290c67 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -863,7 +863,7 @@ namespace SourceGit.ViewModels public void UpdateSubmodules() { if (PopupHost.CanCreatePopup()) - PopupHost.ShowAndStartPopup(new UpdateSubmodules(this)); + PopupHost.ShowPopup(new UpdateSubmodules(this)); } public void OpenSubmodule(string submodule) diff --git a/src/ViewModels/UpdateSubmodules.cs b/src/ViewModels/UpdateSubmodules.cs index 56064317..2e381900 100644 --- a/src/ViewModels/UpdateSubmodules.cs +++ b/src/ViewModels/UpdateSubmodules.cs @@ -1,28 +1,82 @@ -using System.Threading.Tasks; +using System.Collections.Generic; +using System.Threading.Tasks; namespace SourceGit.ViewModels { public class UpdateSubmodules : Popup { + public List Submodules + { + get => _repo.Submodules; + } + + public string SelectedSubmodule + { + get; + set; + } + + public bool UpdateAll + { + get => _updateAll; + set => SetProperty(ref _updateAll, value); + } + + public bool EnableInit + { + get; + set; + } = true; + + public bool EnableRecursive + { + get; + set; + } = true; + + public bool EnableRemote + { + get; + set; + } = false; + public UpdateSubmodules(Repository repo) { _repo = repo; + SelectedSubmodule = repo.Submodules.Count > 0 ? repo.Submodules[0] : string.Empty; View = new Views.UpdateSubmodules() { DataContext = this }; } public override Task Sure() { _repo.SetWatcherEnabled(false); - ProgressDescription = "Updating submodules ..."; + + string target = string.Empty; + if (_updateAll) + { + ProgressDescription = "Updating submodules ..."; + } + else + { + target = SelectedSubmodule; + ProgressDescription = $"Updating submodule {target} ..."; + } return Task.Run(() => { - new Commands.Submodule(_repo.FullPath).Update(SetProgressDescription); + new Commands.Submodule(_repo.FullPath).Update( + target, + EnableInit, + EnableRecursive, + EnableRemote, + SetProgressDescription); + CallUIThread(() => _repo.SetWatcherEnabled(true)); return true; }); } private readonly Repository _repo = null; + private bool _updateAll = true; } } diff --git a/src/Views/UpdateSubmodules.axaml b/src/Views/UpdateSubmodules.axaml index 5ea93fac..f189b80d 100644 --- a/src/Views/UpdateSubmodules.axaml +++ b/src/Views/UpdateSubmodules.axaml @@ -10,8 +10,42 @@ - + + + + + + + + + + + + + + + + + + + + +