Skip to content

Commit c76b770

Browse files
committed
refactor: diff command parameters generation
Signed-off-by: leo <[email protected]>
1 parent 4fcb12b commit c76b770

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/Commands/Diff.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics;
4+
using System.Text;
45
using System.Text.RegularExpressions;
56
using System.Threading.Tasks;
67

@@ -25,12 +26,16 @@ public Diff(string repo, Models.DiffOption opt, int unified, bool ignoreWhitespa
2526
WorkingDirectory = repo;
2627
Context = repo;
2728

29+
var builder = new StringBuilder(256);
30+
builder.Append("diff --no-color --no-ext-diff --patch ");
31+
if (Models.DiffOption.IgnoreCRAtEOL)
32+
builder.Append("--ignore-cr-at-eol ");
2833
if (ignoreWhitespace)
29-
Args = $"diff --no-color --no-ext-diff --patch --ignore-space-change --ignore-cr-at-eol --unified={unified} {opt}";
30-
else if (Models.DiffOption.IgnoreCRAtEOL)
31-
Args = $"diff --no-color --no-ext-diff --patch --ignore-cr-at-eol --unified={unified} {opt}";
32-
else
33-
Args = $"diff --no-color --no-ext-diff --patch --unified={unified} {opt}";
34+
builder.Append("--ignore-space-change ");
35+
builder.Append("--unified=").Append(unified).Append(' ');
36+
builder.Append(opt.ToString());
37+
38+
Args = builder.ToString();
3439
}
3540

3641
public async Task<Models.DiffResult> ReadAsync()

0 commit comments

Comments
 (0)