Skip to content

Commit fb04bec

Browse files
author
Guillaume Rouchon
committed
Add support for GitVersion.yml configuration file
1 parent 704bdfa commit fb04bec

File tree

10 files changed

+57
-15
lines changed

10 files changed

+57
-15
lines changed
File renamed without changes.

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ There are a number of sources GitVersion can get it's versions from, they includ
1919
- Version numbers in branches (i.e `release/2.0.0`)
2020
- Merge messages (for branches with versions in them, i.e `Merged branch 'release/2.0.0' into master`)
2121
- Track version of another branch (i.e develop tracks master, so when master increments so does develop)
22-
- GitVersionConfig.yaml file (i.e `next-version: 2.0.0`)
22+
- GitVersion.yml file (i.e `next-version: 2.0.0`)
2323

2424
Read more at [version sources](more-info/version-sources.md)
2525

docs/more-info/version-increments.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ The options for `commit-message-incrementing` are `Enabled`, `MergeMessageOnly`
3939

4040
If the incrementing mode is set to `MergeMessageOnly` you can add this information in when merging a pull request. This prevents commits within a PR bumping the version.
4141

42-
### GitVersionConfig.yaml
43-
The first is by setting the `next-version` property in the GitVersionConfig.yaml file. This property only serves as a base version,
42+
### GitVersion.yml
43+
The first is by setting the `next-version` property in the GitVersion.yml file. This property only serves as a base version,
4444

4545
### Branch name
4646
If you create a branch with the version number in the branch name such as `release-1.2.0` or `hotfix/1.0.1` then GitVersion will take the version number from the branch name as a source

docs/more-info/version-sources.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ If a branch with a version number in it is merged into the current branch, that
2626

2727
Will increment: false
2828

29-
### GitVersionConfig.yaml
29+
### GitVersion.yml
3030
If the `next-version` property is specified in the config file, it will be used as a version source.
3131

3232
Will increment: false

src/GitVersion.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1717
..\BREAKING CHANGES.md = ..\BREAKING CHANGES.md
1818
..\Build.cmd = ..\Build.cmd
1919
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
20-
..\GitVersionConfig.yaml = ..\GitVersionConfig.yaml
20+
..\GitVersion.yml = ..\GitVersion.yml
2121
..\LICENSE = ..\LICENSE
2222
..\mkdocs.yml = ..\mkdocs.yml
2323
..\README.md = ..\README.md

src/GitVersionCore.Tests/ConfigProviderTests.cs

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void CanReadOldDocument()
6262
";
6363
SetupConfigFileContent(text);
6464
var error = Should.Throw<OldConfigurationException>(() => ConfigurationProvider.Provide(repoPath, fileSystem));
65-
error.Message.ShouldContainWithoutWhitespace(@"GitVersionConfig.yaml contains old configuration, please fix the following errors:
65+
error.Message.ShouldContainWithoutWhitespace(@"GitVersion configuration file contains old configuration, please fix the following errors:
6666
assemblyVersioningScheme has been replaced by assembly-versioning-scheme
6767
develop-branch-tag has been replaced by branch specific configuration.See http://gitversion.readthedocs.org/en/latest/configuration/#branch-configuration
6868
release-branch-tag has been replaced by branch specific configuration.See http://gitversion.readthedocs.org/en/latest/configuration/#branch-configuration");
@@ -209,8 +209,36 @@ public void VerifyAliases()
209209
propertiesMissingAlias.ShouldBeEmpty();
210210
}
211211

212-
void SetupConfigFileContent(string text)
212+
[Test]
213+
public void WarnOnExistingGitVersionConfigYamlFile()
214+
{
215+
SetupConfigFileContent(string.Empty, "GitVersionConfig.yaml");
216+
217+
var s = string.Empty;
218+
Action<string> action = info => { s = info; };
219+
Logger.SetLoggers(action, action, action);
220+
221+
ConfigurationProvider.Provide(repoPath, fileSystem);
222+
223+
s.Contains("'GitVersionConfig.yaml' is deprecated, use 'GitVersion.yml' instead.").ShouldBe(true);
224+
}
225+
226+
[Test]
227+
public void NoWarnOnGitVersionYmlFile()
228+
{
229+
SetupConfigFileContent(string.Empty);
230+
231+
var s = string.Empty;
232+
Action<string> action = info => { s = info; };
233+
Logger.SetLoggers(action, action, action);
234+
235+
ConfigurationProvider.Provide(repoPath, fileSystem);
236+
237+
s.Length.ShouldBe(0);
238+
}
239+
240+
void SetupConfigFileContent(string text, string fileName = "GitVersion.yml")
213241
{
214-
fileSystem.WriteAllText(Path.Combine(repoPath, "GitVersionConfig.yaml"), text);
242+
fileSystem.WriteAllText(Path.Combine(repoPath, fileName), text);
215243
}
216244
}

src/GitVersionCore.Tests/Init/InitScenarios.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void CanSetNextVersion()
1818
var testConsole = new TestConsole("3", "2.0.0", "0");
1919
ConfigurationProvider.Init("c:\\proj", testFileSystem, testConsole);
2020

21-
testFileSystem.ReadAllText("c:\\proj\\GitVersionConfig.yaml").ShouldMatchApproved();
21+
testFileSystem.ReadAllText("c:\\proj\\GitVersion.yml").ShouldMatchApproved();
2222
}
2323

2424
[Test]

src/GitVersionCore/Configuration/ConfigurationProvider.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public static void ApplyBranchDefaults(Config config,
119119

120120
static Config ReadConfig(string workingDirectory, IFileSystem fileSystem)
121121
{
122-
var configFilePath = GetConfigFilePath(workingDirectory);
122+
var configFilePath = GetConfigFilePath(workingDirectory, fileSystem);
123123

124124
if (fileSystem.Exists(configFilePath))
125125
{
@@ -144,14 +144,28 @@ public static string GetEffectiveConfigAsString(string gitDirectory, IFileSystem
144144
return stringBuilder.ToString();
145145
}
146146

147-
static string GetConfigFilePath(string workingDirectory)
147+
static string GetConfigFilePath(string workingDirectory, IFileSystem fileSystem)
148148
{
149-
return Path.Combine(workingDirectory, "GitVersionConfig.yaml");
149+
var ymlPath = Path.Combine(workingDirectory, "GitVersion.yml");
150+
if (fileSystem.Exists(ymlPath))
151+
{
152+
return ymlPath;
153+
}
154+
155+
var yamlPath = Path.Combine(workingDirectory, "GitVersionConfig.yaml");
156+
if (fileSystem.Exists(yamlPath))
157+
{
158+
Logger.WriteWarning("'GitVersionConfig.yaml' is deprecated, use 'GitVersion.yml' instead.");
159+
160+
return yamlPath;
161+
}
162+
163+
return ymlPath;
150164
}
151165

152166
public static void Init(string workingDirectory, IFileSystem fileSystem, IConsole console)
153167
{
154-
var configFilePath = GetConfigFilePath(workingDirectory);
168+
var configFilePath = GetConfigFilePath(workingDirectory, fileSystem);
155169
var currentConfiguration = Provide(workingDirectory, fileSystem, applyDefaults: false);
156170
var config = new ConfigInitWizard(console, fileSystem).Run(currentConfiguration, workingDirectory);
157171
if (config == null) return;

src/GitVersionCore/Configuration/LegacyConfigNotifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static void Notify(StringReader reader)
2727
issues.Add("release-branch-tag has been replaced by branch specific configuration. See http://gitversion.readthedocs.org/en/latest/configuration/#branch-configuration");
2828

2929
if (issues.Any())
30-
throw new OldConfigurationException("GitVersionConfig.yaml contains old configuration, please fix the following errors:\r\n" + string.Join("\r\n", issues));
30+
throw new OldConfigurationException("GitVersion configuration file contains old configuration, please fix the following errors:\r\n" + string.Join("\r\n", issues));
3131
}
3232
}
3333
}

src/GitVersionCore/VersionCalculation/BaseVersionCalculators/ConfigNextVersionBaseVersionStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public override IEnumerable<BaseVersion> GetVersions(GitVersionContext context)
99
if (string.IsNullOrEmpty(context.Configuration.NextVersion) || context.IsCurrentCommitTagged)
1010
yield break;
1111
var semanticVersion = SemanticVersion.Parse(context.Configuration.NextVersion, context.Configuration.GitTagPrefix);
12-
yield return new BaseVersion("NextVersion in GitVersionConfig.yaml", false, semanticVersion, null, null);
12+
yield return new BaseVersion("NextVersion in GitVersion configuration file", false, semanticVersion, null, null);
1313
}
1414
}
1515
}

0 commit comments

Comments
 (0)