Skip to content

Commit c187015

Browse files
committed
added GitVersionOptions similar to Arguments
GitVersionOptions is used internally Arguments is used in the Exe and is transformed into GitVersionOptions
1 parent c5ac846 commit c187015

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+444
-292
lines changed

src/GitVersionCore.Tests/Configuration/ConfigProviderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class ConfigProviderTests : TestBase
3333
public void Setup()
3434
{
3535
repoPath = DefaultRepoPath;
36-
var options = Options.Create(new Arguments { TargetPath = repoPath });
36+
var options = Options.Create(new GitVersionOptions { WorkingDirectory = repoPath });
3737
var sp = ConfigureServices(services =>
3838
{
3939
services.AddSingleton(options);
@@ -264,7 +264,7 @@ public void NoWarnOnGitVersionYmlFile()
264264
var logAppender = new TestLogAppender(Action);
265265
var log = new Log(logAppender);
266266

267-
var options = Options.Create(new Arguments { TargetPath = repoPath });
267+
var options = Options.Create(new GitVersionOptions { WorkingDirectory = repoPath });
268268
var sp = ConfigureServices(services =>
269269
{
270270
services.AddSingleton(options);

src/GitVersionCore.Tests/Configuration/DefaultConfigFileLocatorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void Setup()
2626
{
2727
repoPath = DefaultRepoPath;
2828
workingPath = DefaultWorkingPath;
29-
var options = Options.Create(new Arguments { TargetPath = repoPath });
29+
var options = Options.Create(new GitVersionOptions { WorkingDirectory = repoPath });
3030

3131
var sp = ConfigureServices(services =>
3232
{

src/GitVersionCore.Tests/Configuration/Init/InitScenarios.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void Setup()
2626
public void CanSetNextVersion()
2727
{
2828
var workingDirectory = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:\\proj" : "/proj";
29-
var options = Options.Create(new Arguments { TargetPath = workingDirectory });
29+
var options = Options.Create(new GitVersionOptions { WorkingDirectory = workingDirectory });
3030

3131
var sp = ConfigureServices(services =>
3232
{

src/GitVersionCore.Tests/Configuration/NamedConfigFileLocatorTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public class NamedConfigFileLocatorTests : TestBase
2121
private string workingPath;
2222
private IFileSystem fileSystem;
2323
private IConfigFileLocator configFileLocator;
24-
private Arguments arguments;
24+
private GitVersionOptions gitVersionOptions;
2525

2626
[SetUp]
2727
public void Setup()
2828
{
29-
arguments = new Arguments { ConfigFile = "my-config.yaml" };
29+
gitVersionOptions = new GitVersionOptions { ConfigInfo = { ConfigFile = "my-config.yaml" } };
3030
repoPath = DefaultRepoPath;
3131
workingPath = DefaultWorkingPath;
3232

@@ -36,7 +36,7 @@ public void Setup()
3636
[Test]
3737
public void ThrowsExceptionOnAmbiguousConfigFileLocation()
3838
{
39-
var sp = GetServiceProvider(arguments);
39+
var sp = GetServiceProvider(gitVersionOptions);
4040
configFileLocator = sp.GetService<IConfigFileLocator>();
4141
fileSystem = sp.GetService<IFileSystem>();
4242

@@ -54,7 +54,7 @@ public void DoNotThrowWhenWorkingAndRepoPathsAreSame()
5454
{
5555
workingPath = DefaultRepoPath;
5656

57-
var sp = GetServiceProvider(arguments);
57+
var sp = GetServiceProvider(gitVersionOptions);
5858
configFileLocator = sp.GetService<IConfigFileLocator>();
5959
fileSystem = sp.GetService<IFileSystem>();
6060

@@ -68,7 +68,7 @@ public void DoNotThrowWhenWorkingAndRepoPathsAreSame_WithDifferentCasing()
6868
{
6969
workingPath = DefaultRepoPath.ToLower();
7070

71-
var sp = GetServiceProvider(arguments);
71+
var sp = GetServiceProvider(gitVersionOptions);
7272
configFileLocator = sp.GetService<IConfigFileLocator>();
7373
fileSystem = sp.GetService<IFileSystem>();
7474

@@ -82,8 +82,8 @@ public void DoNotThrowWhenConfigFileIsInSubDirectoryOfRepoPath()
8282
{
8383
workingPath = DefaultRepoPath;
8484

85-
arguments = new Arguments { ConfigFile = "./src/my-config.yaml" };
86-
var sp = GetServiceProvider(arguments);
85+
gitVersionOptions = new GitVersionOptions { ConfigInfo = { ConfigFile = "./src/my-config.yaml" } };
86+
var sp = GetServiceProvider(gitVersionOptions);
8787
configFileLocator = sp.GetService<IConfigFileLocator>();
8888
fileSystem = sp.GetService<IFileSystem>();
8989

@@ -101,7 +101,7 @@ public void NoWarnOnCustomYmlFile()
101101
var logAppender = new TestLogAppender(Action);
102102
var log = new Log(logAppender);
103103

104-
var sp = GetServiceProvider(arguments, log);
104+
var sp = GetServiceProvider(gitVersionOptions, log);
105105
configFileLocator = sp.GetService<IConfigFileLocator>();
106106
fileSystem = sp.GetService<IFileSystem>();
107107

@@ -122,7 +122,7 @@ public void NoWarnOnCustomYmlFileOutsideRepoPath()
122122
var logAppender = new TestLogAppender(Action);
123123
var log = new Log(logAppender);
124124

125-
var sp = GetServiceProvider(arguments, log);
125+
var sp = GetServiceProvider(gitVersionOptions, log);
126126
configFileLocator = sp.GetService<IConfigFileLocator>();
127127
fileSystem = sp.GetService<IFileSystem>();
128128

@@ -137,13 +137,13 @@ public void NoWarnOnCustomYmlFileOutsideRepoPath()
137137
[Test]
138138
public void ThrowsExceptionOnCustomYmlFileDoesNotExist()
139139
{
140-
var sp = GetServiceProvider(arguments);
140+
var sp = GetServiceProvider(gitVersionOptions);
141141
configFileLocator = sp.GetService<IConfigFileLocator>();
142142

143143
var exception = Should.Throw<WarningException>(() => { configFileLocator.Verify(workingPath, repoPath); });
144144

145-
var workingPathFileConfig = Path.Combine(workingPath, arguments.ConfigFile);
146-
var repoPathFileConfig = Path.Combine(repoPath, arguments.ConfigFile);
145+
var workingPathFileConfig = Path.Combine(workingPath, gitVersionOptions.ConfigInfo.ConfigFile);
146+
var repoPathFileConfig = Path.Combine(repoPath, gitVersionOptions.ConfigInfo.ConfigFile);
147147
var expectedMessage = $"The configuration file was not found at '{workingPathFileConfig}' or '{repoPathFileConfig}'";
148148
exception.Message.ShouldBe(expectedMessage);
149149
}
@@ -158,12 +158,12 @@ private string SetupConfigFileContent(string text, string fileName = null, strin
158158
return filePath;
159159
}
160160

161-
private static IServiceProvider GetServiceProvider(Arguments arguments, ILog log = null)
161+
private static IServiceProvider GetServiceProvider(GitVersionOptions gitVersionOptions, ILog log = null)
162162
{
163163
return ConfigureServices(services =>
164164
{
165165
if (log != null) services.AddSingleton(log);
166-
services.AddSingleton(Options.Create(arguments));
166+
services.AddSingleton(Options.Create(gitVersionOptions));
167167
});
168168
}
169169
}

src/GitVersionCore.Tests/Core/DynamicRepositoryTests.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,19 @@ public void FindsVersionInDynamicRepo(string name, string url, string targetBran
6060
var root = Path.Combine(workDirectory, name);
6161
var dynamicDirectory = Path.Combine(root, "D"); // dynamic, keeping directory as short as possible
6262
var workingDirectory = Path.Combine(root, "W"); // working, keeping directory as short as possible
63-
var arguments = new Arguments
63+
var gitVersionOptions = new GitVersionOptions
6464
{
65-
TargetUrl = url,
66-
DynamicRepositoryClonePath = dynamicDirectory,
67-
TargetBranch = targetBranch,
65+
RepositoryInfo =
66+
{
67+
TargetUrl = url,
68+
DynamicRepositoryClonePath = dynamicDirectory,
69+
TargetBranch = targetBranch,
70+
CommitId = commitId,
71+
},
6872
NoFetch = false,
69-
TargetPath = workingDirectory,
70-
CommitId = commitId
73+
WorkingDirectory = workingDirectory,
7174
};
72-
var options = Options.Create(arguments);
75+
var options = Options.Create(gitVersionOptions);
7376

7477
Directory.CreateDirectory(dynamicDirectory);
7578
Directory.CreateDirectory(workingDirectory);

0 commit comments

Comments
 (0)