From d4a9343eafa773bf2136188d106ad51d6add2bd8 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 20 Aug 2024 15:20:58 +0800 Subject: [PATCH] feature: add an option to enable `--recurse-submodules=check` on push (#345) --- src/Commands/Push.cs | 4 +++- src/Models/RepositorySettings.cs | 6 ++++++ src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/Push.cs | 26 +++++++++++++++++++------- src/Views/Push.axaml | 10 ++++++++-- 7 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/Commands/Push.cs b/src/Commands/Push.cs index 31a69eb9..69b859ab 100644 --- a/src/Commands/Push.cs +++ b/src/Commands/Push.cs @@ -4,7 +4,7 @@ namespace SourceGit.Commands { public class Push : Command { - public Push(string repo, string local, string remote, string remoteBranch, bool withTags, bool force, bool track, Action onProgress) + public Push(string repo, string local, string remote, string remoteBranch, bool withTags, bool checkSubmodules, bool track, bool force, Action onProgress) { _outputHandler = onProgress; @@ -16,6 +16,8 @@ namespace SourceGit.Commands if (withTags) Args += "--tags "; + if (checkSubmodules) + Args += "--recurse-submodules=check "; if (track) Args += "-u "; if (force) diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index 788e00a8..06e60a87 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -40,6 +40,12 @@ namespace SourceGit.Models set; } = true; + public bool CheckSubmodulesOnPush + { + get; + set; + } = true; + public bool PushAllTags { get; diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 57e199ac..88634189 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -430,6 +430,7 @@ Pull (Fetch & Merge) Use rebase instead of merge Push + Make sure submodules have been pushed Force push Local Branch: Remote: diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 3aa37333..b7c3e5d1 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -433,6 +433,7 @@ 拉回(拉取并合并) 使用变基方式合并分支 推送(push) + 确保子模块变更已推送 启用强制推送 本地分支 : 远程仓库 : diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 682335b7..6d51c588 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -433,6 +433,7 @@ 拉回(拉取併合並) 使用變基方式合併分支 推送(push) + 確保子模組變更已推送 啟用強制推送 本地分支 : 遠端倉庫 : diff --git a/src/ViewModels/Push.cs b/src/ViewModels/Push.cs index e80c7c78..b3ef694b 100644 --- a/src/ViewModels/Push.cs +++ b/src/ViewModels/Push.cs @@ -62,12 +62,6 @@ namespace SourceGit.ViewModels } } - public bool PushAllTags - { - get => _repo.Settings.PushAllTags; - set => _repo.Settings.PushAllTags = value; - } - public bool IsSetTrackOptionVisible { get => _isSetTrackOptionVisible; @@ -80,6 +74,23 @@ namespace SourceGit.ViewModels set; } = true; + public bool IsCheckSubmodulesVisible + { + get => _repo.Submodules.Count > 0; + } + + public bool CheckSubmodules + { + get; + set; + } = true; + + public bool PushAllTags + { + get => _repo.Settings.PushAllTags; + set => _repo.Settings.PushAllTags = value; + } + public bool ForcePush { get; @@ -151,8 +162,9 @@ namespace SourceGit.ViewModels _selectedRemote.Name, remoteBranchName, PushAllTags, - ForcePush, + _repo.Submodules.Count > 0 && CheckSubmodules, _isSetTrackOptionVisible && Tracking, + ForcePush, SetProgressDescription).Exec(); CallUIThread(() => _repo.SetWatcherEnabled(true)); return succ; diff --git a/src/Views/Push.axaml b/src/Views/Push.axaml index 0720ab24..2d1e9232 100644 --- a/src/Views/Push.axaml +++ b/src/Views/Push.axaml @@ -12,7 +12,7 @@ Classes="bold" Text="{DynamicResource Text.Push.Title}"/> - + + + -