Skip to content

Commit 2d24244

Browse files
committed
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
1 parent d3991c6 commit 2d24244

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/Commands/Checkout.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ public Checkout(string repo)
1414

1515
public bool Branch(string branch, Action<string> onProgress)
1616
{
17-
Args = $"checkout --progress {branch}";
17+
Args = $"checkout --recurse-submodules --progress {branch}";
1818
TraitErrorAsOutput = true;
1919
_outputHandler = onProgress;
2020
return Exec();
2121
}
2222

2323
public bool Branch(string branch, string basedOn, Action<string> onProgress)
2424
{
25-
Args = $"checkout --progress -b {branch} {basedOn}";
25+
Args = $"checkout --recurse-submodules --progress -b {branch} {basedOn}";
2626
TraitErrorAsOutput = true;
2727
_outputHandler = onProgress;
2828
return Exec();
2929
}
3030

3131
public bool UseTheirs(List<string> files)
3232
{
33-
StringBuilder builder = new StringBuilder();
33+
var builder = new StringBuilder();
3434
builder.Append("checkout --theirs --");
3535
foreach (var f in files)
3636
{
@@ -44,7 +44,7 @@ public bool UseTheirs(List<string> files)
4444

4545
public bool UseMine(List<string> files)
4646
{
47-
StringBuilder builder = new StringBuilder();
47+
var builder = new StringBuilder();
4848
builder.Append("checkout --ours --");
4949
foreach (var f in files)
5050
{
@@ -70,20 +70,6 @@ public bool Commit(string commitId, Action<string> onProgress)
7070
return Exec();
7171
}
7272

73-
public bool Files(List<string> files)
74-
{
75-
StringBuilder builder = new StringBuilder();
76-
builder.Append("checkout -f -q --");
77-
foreach (var f in files)
78-
{
79-
builder.Append(" \"");
80-
builder.Append(f);
81-
builder.Append("\"");
82-
}
83-
Args = builder.ToString();
84-
return Exec();
85-
}
86-
8773
protected override void OnReadline(string line)
8874
{
8975
_outputHandler?.Invoke(line);

0 commit comments

Comments
 (0)