diff --git a/src/Commands/Submodule.cs b/src/Commands/Submodule.cs index 428c10d1..3c4460ea 100644 --- a/src/Commands/Submodule.cs +++ b/src/Commands/Submodule.cs @@ -29,9 +29,10 @@ namespace SourceGit.Commands } } - public bool Update() + public bool Update(Action outputHandler) { Args = $"submodule update --rebase --remote"; + _outputHandler = outputHandler; return Exec(); } diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index b5a96ecd..ad919346 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -458,6 +458,8 @@ Delete${0}$ Push${0}$ URL : + Update Submodules + Run `submodule update` command for this repository. Warning Create Group Create Sub-Group diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index f1c5a95f..ba330800 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -461,6 +461,8 @@ 删除${0}$ 推送${0}$ 仓库地址 : + 更新子模块 + 为此仓库执行`submodule update`命令,更新所有的子模块。 警告 新建分组 新建子分组 diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index cef2dddc..65ee45f2 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -769,6 +769,12 @@ namespace SourceGit.ViewModels PopupHost.ShowPopup(new AddSubmodule(this)); } + public void UpdateSubmodules() + { + if (PopupHost.CanCreatePopup()) + PopupHost.ShowAndStartPopup(new UpdateSubmodules(this)); + } + public ContextMenu CreateContextMenuForGitFlow() { var menu = new ContextMenu(); diff --git a/src/ViewModels/UpdateSubmodules.cs b/src/ViewModels/UpdateSubmodules.cs new file mode 100644 index 00000000..56064317 --- /dev/null +++ b/src/ViewModels/UpdateSubmodules.cs @@ -0,0 +1,28 @@ +using System.Threading.Tasks; + +namespace SourceGit.ViewModels +{ + public class UpdateSubmodules : Popup + { + public UpdateSubmodules(Repository repo) + { + _repo = repo; + View = new Views.UpdateSubmodules() { DataContext = this }; + } + + public override Task Sure() + { + _repo.SetWatcherEnabled(false); + ProgressDescription = "Updating submodules ..."; + + return Task.Run(() => + { + new Commands.Submodule(_repo.FullPath).Update(SetProgressDescription); + CallUIThread(() => _repo.SetWatcherEnabled(true)); + return true; + }); + } + + private readonly Repository _repo = null; + } +} diff --git a/src/Views/Repository.axaml.cs b/src/Views/Repository.axaml.cs index 97aa01f3..1eadb7ac 100644 --- a/src/Views/Repository.axaml.cs +++ b/src/Views/Repository.axaml.cs @@ -306,16 +306,10 @@ namespace SourceGit.Views e.Handled = true; } - private async void UpdateSubmodules(object sender, RoutedEventArgs e) + private void UpdateSubmodules(object sender, RoutedEventArgs e) { if (DataContext is ViewModels.Repository repo) - { - repo.SetWatcherEnabled(false); - iconSubmoduleUpdate.Classes.Add("rotating"); - await Task.Run(() => new Commands.Submodule(repo.FullPath).Update()); - iconSubmoduleUpdate.Classes.Remove("rotating"); - repo.SetWatcherEnabled(true); - } + repo.UpdateSubmodules(); e.Handled = true; } diff --git a/src/Views/UpdateSubmodules.axaml b/src/Views/UpdateSubmodules.axaml new file mode 100644 index 00000000..5ea93fac --- /dev/null +++ b/src/Views/UpdateSubmodules.axaml @@ -0,0 +1,17 @@ + + + + + + diff --git a/src/Views/UpdateSubmodules.axaml.cs b/src/Views/UpdateSubmodules.axaml.cs new file mode 100644 index 00000000..165c809a --- /dev/null +++ b/src/Views/UpdateSubmodules.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace SourceGit.Views +{ + public partial class UpdateSubmodules : UserControl + { + public UpdateSubmodules() + { + InitializeComponent(); + } + } +}