Skip to content

Commit b722f72

Browse files
committed
added GitVersionOptions similar to Arguments
1 parent 62eb4af commit b722f72

File tree

12 files changed

+36
-23
lines changed

12 files changed

+36
-23
lines changed

src/GitVersionCore.Tests/Core/DynamicRepositoryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void FindsVersionInDynamicRepo(string name, string url, string targetBran
6969
TargetBranch = targetBranch,
7070
CommitId = commitId,
7171
},
72-
NoFetch = false,
72+
Settings = { NoFetch = false },
7373
WorkingDirectory = workingDirectory,
7474
};
7575
var options = Options.Create(gitVersionOptions);

src/GitVersionCore.Tests/Core/GitVersionExecutorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public void NoCacheBypassesCache()
366366
versionVariables = gitVersionCalculator.CalculateVersionVariables();
367367
versionVariables.AssemblySemVer.ShouldBe("4.10.3.0");
368368

369-
gitVersionOptions.NoCache = true;
369+
gitVersionOptions.Settings.NoCache = true;
370370
versionVariables = gitVersionCalculator.CalculateVersionVariables();
371371
versionVariables.AssemblySemVer.ShouldBe("0.1.0.0");
372372
}

src/GitVersionCore.Tests/Core/GitVersionToolDirectoryTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void FindsGitDirectory()
3535
{
3636
try
3737
{
38-
var options = Options.Create(new GitVersionOptions { WorkingDirectory = workDirectory, NoFetch = true });
38+
var options = Options.Create(new GitVersionOptions { WorkingDirectory = workDirectory, Settings = { NoFetch = true } });
3939

4040
var sp = ConfigureServices(services =>
4141
{
@@ -63,7 +63,7 @@ public void FindsGitDirectoryInParent()
6363

6464
try
6565
{
66-
var options = Options.Create(new GitVersionOptions { WorkingDirectory = childDir, NoFetch = true });
66+
var options = Options.Create(new GitVersionOptions { WorkingDirectory = childDir, Settings = { NoFetch = true } });
6767

6868
var sp = ConfigureServices(services =>
6969
{

src/GitVersionCore.Tests/Extensions/GitToolsTestingExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Co
3535
TargetBranch = branch,
3636
CommitId = commitId,
3737
},
38-
OnlyTrackedBranches = onlyTrackedBranches
38+
Settings = { OnlyTrackedBranches = onlyTrackedBranches }
3939
});
4040

4141
var sp = ConfigureServices(services =>

src/GitVersionCore/Core/GitPreparer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void Prepare()
3232
var buildServer = buildServerResolver.Resolve();
3333

3434
// Normalize if we are running on build server
35-
var normalizeGitDirectory = !gitVersionOptions.NoNormalize && buildServer != null;
35+
var normalizeGitDirectory = !gitVersionOptions.Settings.NoNormalize && buildServer != null;
3636
var shouldCleanUpRemotes = buildServer != null && buildServer.ShouldCleanUpRemotes();
3737

3838
var currentBranch = ResolveCurrentBranch(buildServer, gitVersionOptions.RepositoryInfo.TargetBranch, !string.IsNullOrWhiteSpace(gitVersionOptions.RepositoryInfo.DynamicRepositoryClonePath));
@@ -178,7 +178,7 @@ private void NormalizeGitDirectory(AuthenticationInfo auth, string targetBranch,
178178
using (log.IndentLog($"Normalizing git directory for branch '{targetBranch}'"))
179179
{
180180
// Normalize (download branches) before using the branch
181-
GitRepositoryHelper.NormalizeGitDirectory(log, environment, gitDirectory, auth, options.Value.NoFetch, targetBranch, isDynamicRepository);
181+
GitRepositoryHelper.NormalizeGitDirectory(log, environment, gitDirectory, auth, options.Value.Settings.NoFetch, targetBranch, isDynamicRepository);
182182
}
183183
}
184184

src/GitVersionCore/Core/GitVersionContextFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public GitVersionContextFactory(IConfigProvider configProvider, IRepositoryMetad
2525
public GitVersionContext Create(GitVersionOptions gitVersionOptions)
2626
{
2727
var targetBranch = repositoryMetadataProvider.GetTargetBranch(gitVersionOptions.RepositoryInfo.TargetBranch);
28-
return Init(targetBranch, gitVersionOptions.RepositoryInfo.CommitId, gitVersionOptions.OnlyTrackedBranches);
28+
return Init(targetBranch, gitVersionOptions.RepositoryInfo.CommitId, gitVersionOptions.Settings.OnlyTrackedBranches);
2929
}
3030

3131
private GitVersionContext Init(Branch currentBranch, string commitId = null, bool onlyTrackedBranches = false)

src/GitVersionCore/Core/GitVersionTool.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ public VersionVariables CalculateVersionVariables()
5656
var gitVersionOptions = options.Value;
5757

5858
var cacheKey = cacheKeyFactory.Create(gitVersionOptions.ConfigInfo.OverrideConfig);
59-
var versionVariables = gitVersionOptions.NoCache ? default : gitVersionCache.LoadVersionVariablesFromDiskCache(cacheKey);
59+
var versionVariables = gitVersionOptions.Settings.NoCache ? default : gitVersionCache.LoadVersionVariablesFromDiskCache(cacheKey);
6060

6161
if (versionVariables != null) return versionVariables;
6262

6363
var semanticVersion = nextVersionCalculator.FindVersion();
6464
versionVariables = variableProvider.GetVariablesFor(semanticVersion, context.Configuration, context.IsCurrentCommitTagged);
6565

66-
if (gitVersionOptions.NoCache) return versionVariables;
66+
if (gitVersionOptions.Settings.NoCache) return versionVariables;
6767
try
6868
{
6969
gitVersionCache.WriteVariablesToDiskCache(cacheKey, versionVariables);

src/GitVersionCore/Model/GitVersionOptions.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public GitVersionOptions()
2020
ConfigInfo = new ConfigInfo();
2121
WixInfo = new WixInfo();
2222
RepositoryInfo = new RepositoryInfo();
23+
Settings = new Settings();
2324
}
2425

2526
private string workingDirectory;
@@ -37,17 +38,13 @@ public string WorkingDirectory
3738
public ConfigInfo ConfigInfo { get; }
3839
public RepositoryInfo RepositoryInfo { get; }
3940
public WixInfo WixInfo { get; }
41+
public Settings Settings { get; }
4042

4143
public bool Init;
4244
public bool Diag;
4345
public bool IsVersion;
4446
public bool IsHelp;
4547

46-
public bool NoFetch;
47-
public bool NoCache;
48-
public bool NoNormalize;
49-
public bool OnlyTrackedBranches = false;
50-
5148
public string LogFilePath;
5249
public string ShowVariable;
5350
public ISet<OutputType> Output = new HashSet<OutputType>();

src/GitVersionCore/Model/Settings.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace GitVersion
2+
{
3+
public class Settings
4+
{
5+
public bool NoFetch;
6+
public bool NoCache;
7+
public bool NoNormalize;
8+
public bool OnlyTrackedBranches = false;
9+
}
10+
}

src/GitVersionExe/Arguments.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ public GitVersionOptions ToOptions()
8585
DynamicRepositoryClonePath = DynamicRepositoryClonePath,
8686
},
8787

88+
Settings =
89+
{
90+
NoFetch = NoFetch,
91+
NoCache = NoCache,
92+
NoNormalize = NoNormalize,
93+
},
94+
8895
WixInfo =
8996
{
9097
ShouldUpdate = UpdateWixVersionFile,
@@ -95,10 +102,6 @@ public GitVersionOptions ToOptions()
95102
IsVersion = IsVersion,
96103
IsHelp = IsHelp,
97104

98-
NoFetch = NoFetch,
99-
NoCache = NoCache,
100-
NoNormalize = NoNormalize,
101-
102105
LogFilePath = LogFilePath,
103106
ShowVariable = ShowVariable,
104107
Verbosity = Verbosity,

0 commit comments

Comments
 (0)