From 2d24244ee2af51507c10e5ce9b2248990a9f0981 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 1 Oct 2024 21:01:56 +0800 Subject: [PATCH] enhance: auto-update submodules if possible after checking out a branch (#531) * add `--recurse-submodules` to checkout branch command * remove unused method `Commands.Checkout.Files` * code style --- src/Commands/Checkout.cs | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Commands/Checkout.cs b/src/Commands/Checkout.cs index 25f93e89..306d62ff 100644 --- a/src/Commands/Checkout.cs +++ b/src/Commands/Checkout.cs @@ -14,7 +14,7 @@ namespace SourceGit.Commands public bool Branch(string branch, Action onProgress) { - Args = $"checkout --progress {branch}"; + Args = $"checkout --recurse-submodules --progress {branch}"; TraitErrorAsOutput = true; _outputHandler = onProgress; return Exec(); @@ -22,7 +22,7 @@ namespace SourceGit.Commands public bool Branch(string branch, string basedOn, Action onProgress) { - Args = $"checkout --progress -b {branch} {basedOn}"; + Args = $"checkout --recurse-submodules --progress -b {branch} {basedOn}"; TraitErrorAsOutput = true; _outputHandler = onProgress; return Exec(); @@ -30,7 +30,7 @@ namespace SourceGit.Commands public bool UseTheirs(List files) { - StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); builder.Append("checkout --theirs --"); foreach (var f in files) { @@ -44,7 +44,7 @@ namespace SourceGit.Commands public bool UseMine(List files) { - StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); builder.Append("checkout --ours --"); foreach (var f in files) { @@ -70,20 +70,6 @@ namespace SourceGit.Commands return Exec(); } - public bool Files(List files) - { - StringBuilder builder = new StringBuilder(); - builder.Append("checkout -f -q --"); - foreach (var f in files) - { - builder.Append(" \""); - builder.Append(f); - builder.Append("\""); - } - Args = builder.ToString(); - return Exec(); - } - protected override void OnReadline(string line) { _outputHandler?.Invoke(line);