Skip to content

Commit 5c84c80

Browse files
committed
Simplify ArgumentBuilder and remove unused parameters
Refactored the ArgumentBuilder class to reduce complexity by consolidating constructors and eliminating redundant parameters. Removed the obsolete ExecuteIn method that utilized these parameters from GitVersionHelper. Updated the test case to align with the new method signature and ensure functionality remains intact.
1 parent ae6cf3f commit 5c84c80

File tree

2 files changed

+4
-63
lines changed

2 files changed

+4
-63
lines changed

src/GitVersion.App.Tests/Helpers/ArgumentBuilder.cs

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,11 @@
22

33
namespace GitVersion.App.Tests;
44

5-
public class ArgumentBuilder
5+
public class ArgumentBuilder(string? workingDirectory, string? additionalArguments, string? logFile)
66
{
7-
public ArgumentBuilder(string? workingDirectory) => this.WorkingDirectory = workingDirectory;
7+
public string? WorkingDirectory { get; } = workingDirectory;
88

9-
public ArgumentBuilder(string? workingDirectory, string? exec, string? execArgs, string? projectFile, string? projectArgs, string? logFile)
10-
{
11-
this.WorkingDirectory = workingDirectory;
12-
this.exec = exec;
13-
this.execArgs = execArgs;
14-
this.projectFile = projectFile;
15-
this.projectArgs = projectArgs;
16-
this.LogFile = logFile;
17-
}
18-
19-
public ArgumentBuilder(string? workingDirectory, string? additionalArguments, string? logFile)
20-
{
21-
this.WorkingDirectory = workingDirectory;
22-
this.additionalArguments = additionalArguments;
23-
this.LogFile = logFile;
24-
}
25-
26-
public string? WorkingDirectory { get; }
27-
28-
public string? LogFile { get; }
9+
public string? LogFile { get; } = logFile;
2910

3011
public override string ToString()
3112
{
@@ -36,39 +17,13 @@ public override string ToString()
3617
arguments.Append(" /targetpath \"").Append(this.WorkingDirectory).Append('\"');
3718
}
3819

39-
if (!this.exec.IsNullOrWhiteSpace())
40-
{
41-
arguments.Append(" /exec \"").Append(this.exec).Append('\"');
42-
}
43-
44-
if (!this.execArgs.IsNullOrWhiteSpace())
45-
{
46-
arguments.Append(" /execArgs \"").Append(this.execArgs).Append('\"');
47-
}
48-
49-
if (!this.projectFile.IsNullOrWhiteSpace())
50-
{
51-
arguments.Append(" /proj \"").Append(this.projectFile).Append('\"');
52-
}
53-
54-
if (!this.projectArgs.IsNullOrWhiteSpace())
55-
{
56-
arguments.Append(" /projargs \"").Append(this.projectArgs).Append('\"');
57-
}
58-
5920
if (!this.LogFile.IsNullOrWhiteSpace())
6021
{
6122
arguments.Append(" /l \"").Append(this.LogFile).Append('\"');
6223
}
6324

64-
arguments.Append(this.additionalArguments);
25+
arguments.Append(additionalArguments);
6526

6627
return arguments.ToString();
6728
}
68-
69-
private readonly string? additionalArguments;
70-
private readonly string? exec;
71-
private readonly string? execArgs;
72-
private readonly string? projectArgs;
73-
private readonly string? projectFile;
7429
}

src/GitVersion.App.Tests/Helpers/GitVersionHelper.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,6 @@ namespace GitVersion.App.Tests;
77

88
public static class GitVersionHelper
99
{
10-
public static ExecutionResults ExecuteIn(string? workingDirectory,
11-
string? exec = null,
12-
string? execArgs = null,
13-
string? projectFile = null,
14-
string? projectArgs = null,
15-
bool logToFile = true,
16-
params KeyValuePair<string, string?>[] environments
17-
)
18-
{
19-
var logFile = logToFile ? PathHelper.Combine(workingDirectory, "log.txt") : null;
20-
var args = new ArgumentBuilder(workingDirectory, exec, execArgs, projectFile, projectArgs, logFile);
21-
return ExecuteIn(args, environments);
22-
}
23-
2410
public static ExecutionResults ExecuteIn(
2511
string? workingDirectory,
2612
string? arguments,

0 commit comments

Comments
 (0)