refactor: --recursive will always be enabled while initializing or updating submodules

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2026-01-13 15:40:53 +08:00
parent 36702b9f97
commit 3ee3c4e021
11 changed files with 11 additions and 25 deletions

View File

@@ -43,15 +43,13 @@ namespace SourceGit.Commands
return await ExecAsync().ConfigureAwait(false);
}
public async Task<bool> UpdateAsync(List<string> modules, bool init, bool recursive, bool useRemote = false)
public async Task<bool> UpdateAsync(List<string> modules, bool init = false, bool useRemote = false)
{
var builder = new StringBuilder();
builder.Append("submodule update");
builder.Append("submodule update --recursive");
if (init)
builder.Append(" --init");
if (recursive)
builder.Append(" --recursive");
if (useRemote)
builder.Append(" --remote");
if (modules.Count > 0)

View File

@@ -872,7 +872,6 @@
<x:String x:Key="Text.UpdateSubmodules" xml:space="preserve">Update Submodules</x:String>
<x:String x:Key="Text.UpdateSubmodules.All" xml:space="preserve">All submodules</x:String>
<x:String x:Key="Text.UpdateSubmodules.Init" xml:space="preserve">Initialize as needed</x:String>
<x:String x:Key="Text.UpdateSubmodules.Recursive" xml:space="preserve">Traverse submodules recursively</x:String>
<x:String x:Key="Text.UpdateSubmodules.Target" xml:space="preserve">Submodule:</x:String>
<x:String x:Key="Text.UpdateSubmodules.UpdateToRemoteTrackingBranch" xml:space="preserve">Update to submodule's remote tracking branch</x:String>
<x:String x:Key="Text.URL" xml:space="preserve">URL:</x:String>

View File

@@ -73,7 +73,7 @@ namespace SourceGit.ViewModels
if (submodules.Count > 0)
await new Commands.Submodule(_repo.FullPath)
.Use(log)
.UpdateAsync(submodules, false, true);
.UpdateAsync(submodules);
if (needPopStash)
await new Commands.Stash(_repo.FullPath)

View File

@@ -78,7 +78,7 @@ namespace SourceGit.ViewModels
if (submodules.Count > 0)
await new Commands.Submodule(_repo.FullPath)
.Use(log)
.UpdateAsync(submodules, false, true);
.UpdateAsync(submodules);
if (needPopStash)
await new Commands.Stash(_repo.FullPath)

View File

@@ -73,7 +73,7 @@ namespace SourceGit.ViewModels
if (submodules.Count > 0)
await new Commands.Submodule(_repo.FullPath)
.Use(log)
.UpdateAsync(submodules, false, true);
.UpdateAsync(submodules);
if (needPop)
await new Commands.Stash(_repo.FullPath)

View File

@@ -144,7 +144,7 @@ namespace SourceGit.ViewModels
if (submodules.Count > 0)
await new Commands.Submodule(path)
.Use(log)
.UpdateAsync(submodules, true, true);
.UpdateAsync(submodules, true);
}
log.Complete();

View File

@@ -157,7 +157,7 @@ namespace SourceGit.ViewModels
if (submodules.Count > 0)
await new Commands.Submodule(_repo.FullPath)
.Use(log)
.UpdateAsync(submodules, false, true);
.UpdateAsync(submodules);
if (needPopStash)
await new Commands.Stash(_repo.FullPath)

View File

@@ -95,7 +95,7 @@ namespace SourceGit.ViewModels
if (submodules.Count > 0)
await new Commands.Submodule(_repo.FullPath)
.Use(log)
.UpdateAsync(submodules, false, true);
.UpdateAsync(submodules);
}
log.Complete();

View File

@@ -137,7 +137,7 @@ namespace SourceGit.ViewModels
{
var submodules = await new Commands.QueryUpdatableSubmodules(_repo.FullPath, false).GetResultAsync();
if (submodules.Count > 0)
await new Commands.Submodule(_repo.FullPath).Use(log).UpdateAsync(submodules, false, true);
await new Commands.Submodule(_repo.FullPath).Use(log).UpdateAsync(submodules);
if (needPopStash)
await new Commands.Stash(_repo.FullPath).Use(log).PopAsync("stash@{0}");

View File

@@ -39,12 +39,6 @@ namespace SourceGit.ViewModels
set;
} = true;
public bool EnableRecursive
{
get;
set;
} = true;
public bool EnableRemote
{
get;
@@ -93,7 +87,7 @@ namespace SourceGit.ViewModels
await new Commands.Submodule(_repo.FullPath)
.Use(log)
.UpdateAsync(targets, EnableInit, EnableRecursive, EnableRemote);
.UpdateAsync(targets, EnableInit, EnableRemote);
log.Complete();
_repo.MarkSubmodulesDirtyManually();

View File

@@ -18,7 +18,7 @@
Text="{DynamicResource Text.UpdateSubmodules}"/>
</StackPanel>
<Grid Margin="0,16,0,0" RowDefinitions="32,Auto,Auto,32,32" ColumnDefinitions="120,*">
<Grid Margin="0,16,0,0" RowDefinitions="32,Auto,Auto,32" ColumnDefinitions="120,*">
<TextBlock Grid.Row="0" Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
@@ -59,11 +59,6 @@
ToolTip.Tip="--init"/>
<CheckBox Grid.Row="3" Grid.Column="1"
Content="{DynamicResource Text.UpdateSubmodules.Recursive}"
IsChecked="{Binding EnableRecursive, Mode=TwoWay}"
ToolTip.Tip="--recursive"/>
<CheckBox Grid.Row="4" Grid.Column="1"
Content="{DynamicResource Text.UpdateSubmodules.UpdateToRemoteTrackingBranch}"
IsChecked="{Binding EnableRemote, Mode=TwoWay}"
ToolTip.Tip="--remote"/>