Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the logic inheriting BranchConfiguration from parent branch if the IncrementStrategy is set to Inherit #3190

Merged
merged 69 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
5c619d6
The behavior of GitVersion is sometimes not like I would expected it.…
HHobeck Sep 9, 2022
f2ea9df
Okay I changed the unit and agree on the result. It feels very natura…
HHobeck Sep 9, 2022
3c1e64a
Merge branch 'support/5.x' into feature/3101
HHobeck Sep 9, 2022
0431671
Ignore some failing tests
HHobeck Sep 9, 2022
12a6ecc
Fix some tests
HHobeck Sep 9, 2022
2f89159
Set back the default behavior and change the configuration builder: s…
HHobeck Sep 10, 2022
01100f2
Integrate code review feedbacks from Asbjørn Ulsberg.
HHobeck Sep 10, 2022
dcec44f
Set back the default behavior and change the configuration builder: s…
HHobeck Sep 10, 2022
eac6f01
Set back the default behavior and change the configuration builder: s…
HHobeck Sep 10, 2022
8f09a85
Fix WhenPreventIncrementOfMergedBranchVersionIsSetToFalseForDevelopCo…
HHobeck Sep 10, 2022
c62053b
Add ConfigBuilder to make it easier in tests to create configuration …
HHobeck Sep 12, 2022
3c74141
Create test for discussion: Prevent decrementation of versions on the…
HHobeck Sep 12, 2022
937f761
Modify PreventDecrementationOfVersionsOnTheDevelopBranch and remove T…
HHobeck Sep 13, 2022
befa745
The way I'm calculating the effective configuration for each base ver…
HHobeck Sep 15, 2022
ccb9f1f
Remove BranchConfigurationCalculator
HHobeck Sep 15, 2022
55c899d
Run dotnet format
HHobeck Sep 15, 2022
8f226d4
Remove comments out of the test scenarios which I have added.
HHobeck Sep 15, 2022
4e29b80
Change PreventDecrementationOfVersionsOnTheDevelopBranchScenario and …
HHobeck Sep 15, 2022
9f12b5b
Change PreventDecrementationOfVersionsOnTheDevelopBranchScenario
HHobeck Sep 15, 2022
3110909
Move logic from VersionStrategyBase to VersionStrategyBaseWithInherit…
HHobeck Sep 15, 2022
33dc540
Change back some configuration changes like it was before.
HHobeck Sep 15, 2022
de573a5
Fix FindsVersionInDynamicRepo test
HHobeck Sep 16, 2022
a9471d9
run dotnet format ./src/ --exclude **/AddFormats/
HHobeck Sep 16, 2022
39b1abc
Create integration test for [Bug] #3151 and make some minor changes
HHobeck Sep 16, 2022
28a9d2b
Move this logic to the class BaseVersionCalculator and change the int…
HHobeck Sep 17, 2022
f982607
Create unit test for EffectiveBranchConfigurationFinder
HHobeck Sep 17, 2022
7c585f2
Introduce the concept of fallback and unkown branch configuration. Wh…
HHobeck Sep 18, 2022
da04d3f
Mastering the integration tests CreatingAFeatureBranchFromAReleaseBra…
HHobeck Sep 18, 2022
4475e05
Create a new EffectiveBranchConfiguration class which contains the Br…
HHobeck Sep 18, 2022
e43dbf7
Fuse the BaseVersionCalculator with the NextVersionCalculator. No bus…
HHobeck Sep 18, 2022
2531495
Finally I have changed all calls to GitVersionContext::Configuration …
HHobeck Sep 18, 2022
4095244
dotnet format .\src\ --exclude **/AddFormats/
HHobeck Sep 18, 2022
260ee92
Merge branch 'main' into feature/3101
HHobeck Sep 19, 2022
75f4c37
EffectiveBranchConfigurationFinder public and remove one integration …
HHobeck Sep 19, 2022
c6945fc
Rename GetTargetBranches to GetSourceBranches. Fix some warnings and …
HHobeck Sep 20, 2022
e73c92f
Move commented test to EffectiveBranchConfigurationFinderTests.
HHobeck Sep 20, 2022
6a69dce
Move tests aspects from GitVersionContextTests to EffectiveBranchConf…
HHobeck Sep 20, 2022
043264c
Move tests from BaseVersionCalculatorTests to NextVersionCalculatorTe…
HHobeck Sep 20, 2022
8f8e665
Re comment tests in NextVersionCalculatorTests, MergeMessageBaseVersi…
HHobeck Sep 20, 2022
1c9e3cf
Update documentation how-it-works.md
HHobeck Sep 20, 2022
45cf14f
dotnet format ./src/ --exclude **/AddFormats/ --verify-no-changes
HHobeck Sep 20, 2022
8e1670f
Fix some typos
HHobeck Sep 21, 2022
1041d07
Refactoring of EffectiveConfiguration. no business logic changed
HHobeck Oct 1, 2022
5af8026
Move logic call of UpdatePreReleaseTag back to the previous location.
HHobeck Oct 1, 2022
b9cf015
Merge branch 'main' into feature/3101
HHobeck Oct 1, 2022
016d5a7
Integrate code review comments of reviewer asbjornu and arturcic.
HHobeck Oct 3, 2022
f062817
Change PublicAPI.Shipped and Unshipped
HHobeck Oct 3, 2022
a5f3d5e
Merge branch 'GitTools:main' into feature/3101
HHobeck Oct 4, 2022
74db309
Merge branch main into 'feature/3101'
HHobeck Oct 4, 2022
2425546
Merge branch 'main' into feature/3101
asbjornu Oct 4, 2022
2ba1989
Minor refactoring. No business logic changed.
HHobeck Oct 5, 2022
0080e73
Merge branch 'feature/3101' of https://github.com/HHobeck/GitVersion …
HHobeck Oct 5, 2022
ff6f27f
Refactoring of MainlineBranchFinder class.
HHobeck Oct 5, 2022
061c06e
Merge branch 'main' into feature/3101
HHobeck Oct 5, 2022
7f0309b
Integrate code review comments of reviewer asbjornu.
HHobeck Oct 5, 2022
fc2e75d
Integrate code review comments of reviewer asbjornu.
HHobeck Oct 5, 2022
42da619
Merge branch 'feature/3101' of https://github.com/HHobeck/GitVersion …
HHobeck Oct 5, 2022
f39b551
Removing default values from hotfix branch configuration which should…
HHobeck Oct 6, 2022
94e2127
Remove FixTheBaseVersionSourceOfMergeMessageStrategyIfReleaseBranchWa…
HHobeck Oct 7, 2022
af1bf3f
Merge branch 'main' into feature/3101
asbjornu Oct 10, 2022
6bd49cd
Make the effective configuration tag not nullable. Default value for …
HHobeck Oct 11, 2022
4a405c6
Change breaking changes file
HHobeck Oct 11, 2022
410c92e
Change property FullConfiguration to Configuration in GitVersionContext.
HHobeck Oct 11, 2022
f24f235
Merge branch 'feature/3101' of https://github.com/HHobeck/GitVersion …
HHobeck Oct 11, 2022
77095ac
Fix typo in breaking changes
HHobeck Oct 11, 2022
32b0398
Update breaking changes and document some examples
HHobeck Oct 11, 2022
3971272
Change documentation
HHobeck Oct 11, 2022
0800edf
Remove constructing logic of the configuration in GitToolsTestingExte…
HHobeck Oct 11, 2022
1397f03
Update BREAKING_CHANGES.md
HHobeck Oct 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
## Unreleased

* When using a commit message that matches **both** `*-version-bump-message` and `no-bump-message`, there is no increment for that commit. In other words, `no-bump-message` now takes precedence over `*-version-bump-message`.
* The fallback version strategy now returns `0.0.0` and is flagged with `ShouldIncrement` equal to `true`. This yields the version `0.1.0` on the `develop` branch (`IncrementStrategy.Minor` by default) and `0.0.1` on the `main` branch (`IncremetnStrategy.Patch` by default).
* The current branch (child) inherits its configuration from the source (parent) branch if the `increment` strategy is set to `Inherit`. This makes branch configuration recursive, simpler, more intuitive, more flexible, and more robust.
* Instead of having a single effective configuration, we now have one effective configuration per branch where the increment strategy is not set to `inherit`.
* The new implementation of the branch configuration inheritance affects per default only the pull-requests, hotfix and feature branches. In this case the next version will be generated like the child branch is not existing and the commits have been made on the source branch.
asbjornu marked this conversation as resolved.
Show resolved Hide resolved
* The following example illustrates this behavior. On the feature branch the semantic version 1.1.0-just-a-test.1+2 will be generated instead of version 1.0.0-just-a-test.1+3:
HHobeck marked this conversation as resolved.
Show resolved Hide resolved
```
* 1f1cfb4 52 minutes ago (HEAD -> feature/just-a-test)
* 1f9654d 54 minutes ago (release/1.1.0)
* be72411 56 minutes ago (develop)
* 14800ff 58 minutes ago (tag: 1.0.0, main)
```

## v5.0.0

Expand Down
4 changes: 3 additions & 1 deletion docs/input/docs/learn/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ Currently we have the following strategies:
GitVersion.yaml file
* `MergeMessageBaseVersionStrategy` - Finds version numbers from merge messages
(e.g., `Merge 'release/3.0.0' into 'main'` will return `3.0.0`)
* `FallbackBaseVersionStrategy` - Always returns 0.1.0 for new repositories
* `FallbackBaseVersionStrategy` - Always returns 0.0.0 and will be used for
calculating the next version which is dependent on the increment strategy of
the effected branch (e.g. on main the next version is 0.0.1 or on develop it is 0.1.0)

Each strategy needs to return an instance of `BaseVersion` which has the
following properties:
Expand Down
23 changes: 4 additions & 19 deletions docs/input/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,39 +329,24 @@ branches:
feature:
regex: ^features?[/-]
mode: ContinuousDelivery
tag: useBranchName
tag: '{BranchName}'
increment: Inherit
prevent-increment-of-merged-branch-version: false
track-merge-target: false
source-branches: [ 'develop', 'main', 'release', 'feature', 'support', 'hotfix' ]
tracks-release-branches: false
is-release-branch: false
is-mainline: false
pre-release-weight: 30000
pre-release-weight: 30000
pull-request:
regex: ^(pull|pull\-requests|pr)[/-]
mode: ContinuousDelivery
tag: PullRequest
increment: Inherit
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
source-branches: [ 'develop', 'main', 'release', 'feature', 'support', 'hotfix' ]
tracks-release-branches: false
is-release-branch: false
is-mainline: false
pre-release-weight: 30000
hotfix:
regex: ^hotfix(es)?[/-]
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
source-branches: [ 'develop', 'main', 'support' ]
tracks-release-branches: false
is-release-branch: false
is-mainline: false
increment: Inherit
source-branches: [ 'release', 'main', 'support', 'hotfix' ]
pre-release-weight: 30000
support:
regex: ^support[/-]
Expand Down
14 changes: 7 additions & 7 deletions src/GitVersion.App.Tests/JsonOutputOnBuildServerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public void BeingOnBuildServerWithOutputJsonDoesNotFail()
var result = GitVersionHelper.ExecuteIn(fixture.LocalRepositoryFixture.RepositoryPath, arguments: " /output json /output buildserver", environments: env);

result.ExitCode.ShouldBe(0);
const string version = "0.1.0+4";
result.Output.ShouldContain($"##teamcity[buildNumber '{version}']");
const string expectedVersion = "0.0.1+5";
result.Output.ShouldContain($"##teamcity[buildNumber '{expectedVersion}']");
result.OutputVariables.ShouldNotBeNull();
result.OutputVariables.FullSemVer.ShouldBeEquivalentTo(version);
result.OutputVariables.FullSemVer.ShouldBeEquivalentTo(expectedVersion);
}

[TestCase("", "GitVersion.json")]
Expand All @@ -56,16 +56,16 @@ public void BeingOnBuildServerWithOutputJsonAndOutputFileDoesNotFail(string outp
var result = GitVersionHelper.ExecuteIn(fixture.LocalRepositoryFixture.RepositoryPath, arguments: $" /output json /output buildserver /output file /outputfile {outputFile}", environments: env);

result.ExitCode.ShouldBe(0);
const string version = "0.1.0+4";
result.Output.ShouldContain($"##teamcity[buildNumber '{version}']");
const string expectedVersion = "0.0.1+5";
result.Output.ShouldContain($"##teamcity[buildNumber '{expectedVersion}']");
result.OutputVariables.ShouldNotBeNull();
result.OutputVariables.FullSemVer.ShouldBeEquivalentTo(version);
result.OutputVariables.FullSemVer.ShouldBeEquivalentTo(expectedVersion);

var filePath = PathHelper.Combine(fixture.LocalRepositoryFixture.RepositoryPath, fileName);
var json = File.ReadAllText(filePath);

var outputVariables = VersionVariables.FromJson(json);
outputVariables.ShouldNotBeNull();
outputVariables.FullSemVer.ShouldBeEquivalentTo(version);
outputVariables.FullSemVer.ShouldBeEquivalentTo(expectedVersion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,13 @@ branches:
hotfix:
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
increment: Inherit
asbjornu marked this conversation as resolved.
Show resolved Hide resolved
regex: ^hotfix(es)?[/-]
source-branches:
- release
- main
- support
- hotfix
tracks-release-branches: false
is-release-branch: false
is-mainline: false
pre-release-weight: 30000
support:
mode: ContinuousDelivery
Expand Down
12 changes: 6 additions & 6 deletions src/GitVersion.Core.Tests/Core/GitVersionExecutorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void CacheFileExistsOnDisk()
var gitVersionCalculator = GetGitVersionCalculator(gitVersionOptions, this.log);

var versionVariables = gitVersionCalculator.CalculateVersionVariables();
versionVariables.AssemblySemVer.ShouldBe("0.1.0.0");
versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");

this.fileSystem.WriteAllText(versionVariables.FileName, versionCacheFileContent);
versionVariables = gitVersionCalculator.CalculateVersionVariables();
Expand Down Expand Up @@ -197,7 +197,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
var gitVersionCalculator = GetGitVersionCalculator(gitVersionOptions, this.log);

var versionVariables = gitVersionCalculator.CalculateVersionVariables();
versionVariables.AssemblySemVer.ShouldBe("0.1.0.0");
versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");

this.fileSystem.WriteAllText(versionVariables.FileName, versionCacheFileContent);

Expand All @@ -211,7 +211,7 @@ public void CacheFileExistsOnDiskWhenOverrideConfigIsSpecifiedVersionShouldBeDyn
gitVersionCalculator = GetGitVersionCalculator(gitVersionOptions);
versionVariables = gitVersionCalculator.CalculateVersionVariables();

versionVariables.AssemblySemVer.ShouldBe("0.1.0.0");
versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");

var cachedDirectoryTimestampAfter = this.fileSystem.GetLastDirectoryWrite(cacheDirectory);
cachedDirectoryTimestampAfter.ShouldBe(cacheDirectoryTimestamp, "Cache was updated when override config was set");
Expand Down Expand Up @@ -279,7 +279,7 @@ public void ConfigChangeInvalidatesCache()
var gitVersionCalculator = GetGitVersionCalculator(gitVersionOptions);
var versionVariables = gitVersionCalculator.CalculateVersionVariables();

versionVariables.AssemblySemVer.ShouldBe("0.1.0.0");
versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");
versionVariables.FileName.ShouldNotBeNullOrEmpty();

this.fileSystem.WriteAllText(versionVariables.FileName, versionCacheFileContent);
Expand Down Expand Up @@ -336,7 +336,7 @@ public void NoCacheBypassesCache()

var versionVariables = gitVersionCalculator.CalculateVersionVariables();

versionVariables.AssemblySemVer.ShouldBe("0.1.0.0");
versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");
versionVariables.FileName.ShouldNotBeNullOrEmpty();

this.fileSystem.WriteAllText(versionVariables.FileName, versionCacheFileContent);
Expand All @@ -345,7 +345,7 @@ public void NoCacheBypassesCache()

gitVersionOptions.Settings.NoCache = true;
versionVariables = gitVersionCalculator.CalculateVersionVariables();
versionVariables.AssemblySemVer.ShouldBe("0.1.0.0");
versionVariables.AssemblySemVer.ShouldBe("0.0.1.0");
}

[Test]
Expand Down
6 changes: 3 additions & 3 deletions src/GitVersion.Core.Tests/Core/RepositoryStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void FindsCorrectMergeBaseForForwardMerge()

var developMergeBase = gitRepoMetadataProvider.FindMergeBase(develop, release);

fixtureRepository.DumpGraph(Console.WriteLine);
fixtureRepository.DumpGraph();

releaseBranchMergeBase.ShouldBe(expectedReleaseMergeBase);
developMergeBase.ShouldBe(expectedDevelopMergeBase);
Expand Down Expand Up @@ -124,7 +124,7 @@ public void FindsCorrectMergeBaseForForwardMergeMovesOn()

var developMergeBase = gitRepoMetadataProvider.FindMergeBase(develop, release);

fixtureRepository.DumpGraph(Console.WriteLine);
fixtureRepository.DumpGraph();

releaseBranchMergeBase.ShouldBe(expectedReleaseMergeBase);
developMergeBase.ShouldBe(expectedDevelopMergeBase);
Expand Down Expand Up @@ -199,7 +199,7 @@ public void FindsCorrectMergeBaseForMultipleForwardMerges()

var developMergeBase = gitRepoMetadataProvider.FindMergeBase(develop, release);

fixtureRepository.DumpGraph(Console.WriteLine);
fixtureRepository.DumpGraph();

releaseBranchMergeBase.ShouldBe(expectedReleaseMergeBase);
developMergeBase.ShouldBe(expectedDevelopMergeBase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ public static void WriteVersionVariables(this RepositoryFixtureBase fixture, str

public static void AssertFullSemver(this RepositoryFixtureBase fixture, string fullSemver, Config? configuration = null, IRepository? repository = null, string? commitId = null, bool onlyTrackedBranches = true, string? targetBranch = null)
{
configuration ??= new Config();
configuration = new ConfigurationBuilder().Add(configuration).Build();
Console.WriteLine("---------");

try
Expand Down
6 changes: 3 additions & 3 deletions src/GitVersion.Core.Tests/Helpers/TestConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public sealed class TestConfigurationBuilder
{
public static TestConfigurationBuilder New => new();

private string? nextVerson;
private string? nextVersion;
private VersioningMode? versioningMode;
private readonly Dictionary<string, VersioningMode?> versioningModeDictionary = new();
private bool withoutAnyTrackMergeTargets;
Expand All @@ -28,7 +28,7 @@ private TestConfigurationBuilder()

public TestConfigurationBuilder WithNextVersion(string? value)
{
nextVerson = value;
nextVersion = value;
return this;
}

Expand Down Expand Up @@ -109,7 +109,7 @@ public Config Build()
{
Config configuration = new()
{
NextVersion = nextVerson,
NextVersion = nextVersion,
VersioningMode = versioningMode
};

Expand Down
Loading