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
This commit is contained in:
leo 2024-10-01 21:01:56 +08:00
parent d3991c6535
commit 2d24244ee2
No known key found for this signature in database

View file

@ -14,7 +14,7 @@ namespace SourceGit.Commands
public bool Branch(string branch, Action<string> onProgress) public bool Branch(string branch, Action<string> onProgress)
{ {
Args = $"checkout --progress {branch}"; Args = $"checkout --recurse-submodules --progress {branch}";
TraitErrorAsOutput = true; TraitErrorAsOutput = true;
_outputHandler = onProgress; _outputHandler = onProgress;
return Exec(); return Exec();
@ -22,7 +22,7 @@ namespace SourceGit.Commands
public bool Branch(string branch, string basedOn, Action<string> onProgress) public bool Branch(string branch, string basedOn, Action<string> onProgress)
{ {
Args = $"checkout --progress -b {branch} {basedOn}"; Args = $"checkout --recurse-submodules --progress -b {branch} {basedOn}";
TraitErrorAsOutput = true; TraitErrorAsOutput = true;
_outputHandler = onProgress; _outputHandler = onProgress;
return Exec(); return Exec();
@ -30,7 +30,7 @@ namespace SourceGit.Commands
public bool UseTheirs(List<string> files) public bool UseTheirs(List<string> files)
{ {
StringBuilder builder = new StringBuilder(); var builder = new StringBuilder();
builder.Append("checkout --theirs --"); builder.Append("checkout --theirs --");
foreach (var f in files) foreach (var f in files)
{ {
@ -44,7 +44,7 @@ namespace SourceGit.Commands
public bool UseMine(List<string> files) public bool UseMine(List<string> files)
{ {
StringBuilder builder = new StringBuilder(); var builder = new StringBuilder();
builder.Append("checkout --ours --"); builder.Append("checkout --ours --");
foreach (var f in files) foreach (var f in files)
{ {
@ -70,20 +70,6 @@ namespace SourceGit.Commands
return Exec(); return Exec();
} }
public bool Files(List<string> 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) protected override void OnReadline(string line)
{ {
_outputHandler?.Invoke(line); _outputHandler?.Invoke(line);