Skip to content

Feature branch does not pick up version #1102

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ branches:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: false
tracks-release-branches: false
is-release-branch: false
release:
regex: releases?[/-]
Expand All @@ -172,7 +172,7 @@ branches:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: false
tracks-release-branches: false
is-release-branch: true
feature:
regex: features?[/-]
Expand All @@ -181,7 +181,7 @@ branches:
increment: Inherit
prevent-increment-of-merged-branch-version: false
track-merge-target: false
is-develop: false
tracks-release-branches: false
is-release-branch: false
pull-request:
regex: (pull|pull\-requests|pr)[/-]
Expand All @@ -191,7 +191,7 @@ branches:
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
is-develop: false
tracks-release-branches: false
is-release-branch: false
hotfix:
regex: hotfix(es)?[/-]
Expand All @@ -200,7 +200,7 @@ branches:
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
is-develop: false
tracks-release-branches: false
is-release-branch: false
support:
regex: support[/-]
Expand All @@ -209,7 +209,7 @@ branches:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: false
tracks-release-branches: false
is-release-branch: false
develop:
regex: dev(elop)?(ment)?$
Expand All @@ -218,7 +218,7 @@ branches:
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
is-develop: true
tracks-release-branches: true
is-release-branch: false
```

Expand Down Expand Up @@ -282,7 +282,7 @@ Strategy which will look for tagged merge commits directly off the current
branch. For example `develop` → `release/1.0.0` → merge into `master` and tag
`1.0.0`. The tag is *not* on develop, but develop should be version `1.0.0` now.

### is-develop
### tracks-release-branches
Indicates this branch config represents develop in GitFlow.

### is-release-branch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ branches:
prevent-increment-of-merged-branch-version: true
track-merge-target: false
regex: master
is-develop: false
tracks-release-branches: false
is-release-branch: false
is-mainline: true
release:
Expand All @@ -28,7 +28,7 @@ branches:
prevent-increment-of-merged-branch-version: true
track-merge-target: false
regex: releases?[/-]
is-develop: false
tracks-release-branches: false
is-release-branch: true
is-mainline: false
feature:
Expand All @@ -38,7 +38,7 @@ branches:
prevent-increment-of-merged-branch-version: false
track-merge-target: false
regex: features?[/-]
is-develop: false
tracks-release-branches: false
is-release-branch: false
is-mainline: false
pull-request:
Expand All @@ -49,7 +49,7 @@ branches:
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
regex: (pull|pull\-requests|pr)[/-]
is-develop: false
tracks-release-branches: false
is-release-branch: false
is-mainline: false
hotfix:
Expand All @@ -59,7 +59,7 @@ branches:
prevent-increment-of-merged-branch-version: false
track-merge-target: false
regex: hotfix(es)?[/-]
is-develop: false
tracks-release-branches: false
is-release-branch: false
is-mainline: false
support:
Expand All @@ -69,7 +69,7 @@ branches:
prevent-increment-of-merged-branch-version: true
track-merge-target: false
regex: support[/-]
is-develop: false
tracks-release-branches: false
is-release-branch: false
is-mainline: true
develop:
Expand All @@ -79,7 +79,7 @@ branches:
prevent-increment-of-merged-branch-version: false
track-merge-target: true
regex: dev(elop)?(ment)?$
is-develop: true
tracks-release-branches: true
is-release-branch: false
is-mainline: false
ignore:
Expand Down
19 changes: 19 additions & 0 deletions src/GitVersionCore.Tests/ConfigProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,23 @@ string SetupConfigFileContent(string text, string fileName, string path)

return fullPath;
}

[Test]
public void WarnOnObsoleteIsDevelopBranchConfigurationSetting()
{
const string text = @"
assembly-versioning-scheme: MajorMinorPatch
branches:
master:
tag: beta
is-develop: true";

OldConfigurationException exception = Should.Throw<OldConfigurationException>(() =>
{
LegacyConfigNotifier.Notify(new StringReader(text));
});

var expecedMessage = string.Format("'is-develop' is deprecated, use 'track-release-branches' instead.");
exception.Message.ShouldContain(expecedMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using GitVersionCore.Tests;
using LibGit2Sharp;
using NUnit.Framework;
using System.Collections.Generic;

[TestFixture]
public class FeatureBranchScenarios
Expand Down Expand Up @@ -223,7 +224,7 @@ public void BranchCreatedAfterFinishReleaseShouldInheritAndIncrementFromLastMast
fixture.Checkout("develop");
fixture.Repository.MergeNoFF("release/0.2.0");
fixture.Repository.Branches.Remove("release/2.0.0");

fixture.Repository.MakeACommit();

//validate develop branch version after merging release 0.2.0 to master and develop (finish release)
Expand All @@ -237,4 +238,51 @@ public void BranchCreatedAfterFinishReleaseShouldInheritAndIncrementFromLastMast
fixture.AssertFullSemver("0.3.0-TEST-1.1+2");
}
}
}

[Test]
public void PickUpVersionFromMasterMarkedWithIsTracksReleaseBranches()
{
var config = new Config
{
VersioningMode = VersioningMode.ContinuousDelivery,
Branches = new Dictionary<string, BranchConfig>
{
{
"master", new BranchConfig()
{
Tag = "pre",
TracksReleaseBranches = true,
}
},
{
"release", new BranchConfig()
{
IsReleaseBranch = true,
Tag = "rc",
}
}
}
};

using (var fixture = new EmptyRepositoryFixture())
{
fixture.MakeACommit();

// create a release branch and tag a release
fixture.BranchTo("release/0.10.0");
fixture.MakeACommit();
fixture.MakeACommit();
fixture.AssertFullSemver(config, "0.10.0-rc.1+2");

// switch to master and verify the version
fixture.Checkout("master");
fixture.MakeACommit();
fixture.AssertFullSemver(config, "0.10.1-pre.1+1");

// create a feature branch from master and verify the version
// TODO this will pass once default becomes inherit
//fixture.BranchTo("MyFeatureD");
//fixture.AssertFullSemver(config, "0.10.1-MyFeatureD.1+1");
}
}
}
10 changes: 5 additions & 5 deletions src/GitVersionCore.Tests/TestEffectiveConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace GitVersionCore.Tests
{
using System.Collections.Generic;
using System.Linq;
using GitVersion;
using GitVersion.VersionFilters;
using System.Collections.Generic;
using System.Linq;

public class TestEffectiveConfiguration : EffectiveConfiguration
{
Expand All @@ -28,15 +28,15 @@ public TestEffectiveConfiguration(
int buildMetaDataPadding = 4,
int commitsSinceVersionSourcePadding = 4,
IEnumerable<IVersionFilter> versionFilters = null,
bool isDevelop = false,
bool isRelease = false) :
bool tracksReleaseBranches = false,
bool isRelease = false) :
base(assemblyVersioningScheme, assemblyInformationalFormat, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch,
branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag,
trackMergeTarget,
majorMessage, minorMessage, patchMessage, noBumpMessage,
commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding,
versionFilters ?? Enumerable.Empty<IVersionFilter>(),
isDevelop, isRelease)
tracksReleaseBranches, isRelease)
{
}
}
Expand Down
12 changes: 5 additions & 7 deletions src/GitVersionCore/BranchConfigurationCalculator.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
namespace GitVersion
{
using JetBrains.Annotations;
using LibGit2Sharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

using JetBrains.Annotations;

using LibGit2Sharp;

public class BranchConfigurationCalculator
{
public static KeyValuePair<string, BranchConfig> GetBranchConfiguration(Commit currentCommit, IRepository repository, bool onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList<Branch> excludedInheritBranches = null)
Expand Down Expand Up @@ -48,7 +46,7 @@ static KeyValuePair<string, BranchConfig>[] LookupBranchConfiguration([NotNull]
{
throw new ArgumentNullException("config");
}

if (currentBranch == null)
{
throw new ArgumentNullException("currentBranch");
Expand Down Expand Up @@ -120,7 +118,7 @@ static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEv
Increment = branchConfig.Increment,
PreventIncrementOfMergedBranchVersion = branchConfig.PreventIncrementOfMergedBranchVersion,
// If we are inheriting from develop then we should behave like develop
IsDevelop = branchConfig.IsDevelop
TracksReleaseBranches = branchConfig.TracksReleaseBranches
});
}

Expand Down Expand Up @@ -152,7 +150,7 @@ static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEv
Increment = inheritingBranchConfig.Increment,
PreventIncrementOfMergedBranchVersion = inheritingBranchConfig.PreventIncrementOfMergedBranchVersion,
// If we are inheriting from develop then we should behave like develop
IsDevelop = inheritingBranchConfig.IsDevelop
TracksReleaseBranches = inheritingBranchConfig.TracksReleaseBranches
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/GitVersionCore/Configuration/BranchConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public BranchConfig(BranchConfig branchConfiguration)
TagNumberPattern = branchConfiguration.TagNumberPattern;
TrackMergeTarget = branchConfiguration.TrackMergeTarget;
CommitMessageIncrementing = branchConfiguration.CommitMessageIncrementing;
IsDevelop = branchConfiguration.IsDevelop;
TracksReleaseBranches = branchConfiguration.TracksReleaseBranches;
IsReleaseBranch = branchConfiguration.IsReleaseBranch;
IsMainline = branchConfiguration.IsMainline;
}
Expand All @@ -43,15 +43,15 @@ public BranchConfig(BranchConfig branchConfiguration)

[YamlMember(Alias = "track-merge-target")]
public bool? TrackMergeTarget { get; set; }

[YamlMember(Alias = "commit-message-incrementing")]
public CommitMessageIncrementMode? CommitMessageIncrementing { get; set; }

[YamlMember(Alias = "regex")]
public string Regex { get; set; }

[YamlMember(Alias = "is-develop")]
public bool? IsDevelop { get; set; }
[YamlMember(Alias = "tracks-release-branches")]
public bool? TracksReleaseBranches { get; set; }

[YamlMember(Alias = "is-release-branch")]
public bool? IsReleaseBranch { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/GitVersionCore/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public Config()
[YamlMember(Alias = "next-version")]
public string NextVersion
{
get { return this.nextVersion; }
get { return nextVersion; }
set
{
int major;
this.nextVersion = int.TryParse(value, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out major)
nextVersion = int.TryParse(value, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out major)
? string.Format("{0}.0", major)
: value;
}
Expand Down
9 changes: 5 additions & 4 deletions src/GitVersionCore/Configuration/ConfigurationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace GitVersion
{
using Configuration.Init.Wizard;
using GitVersion.Helpers;
using System;
using System.IO;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -121,10 +122,10 @@ public static void ApplyDefaultsTo(Config config)
defaultIncrementStrategy: IncrementStrategy.Minor,
defaultVersioningMode: VersioningMode.ContinuousDeployment,
defaultTrackMergeTarget: true,
isDevelop: true);
tracksReleaseBranches: true);

// Any user defined branches should have other values defaulted after known branches filled in
// This allows users to override one value of
// This allows users to override one value of
foreach (var branchConfig in configBranches)
{
var regex = branchConfig.Value.Regex;
Expand Down Expand Up @@ -163,7 +164,7 @@ public static void ApplyBranchDefaults(Config config,
VersioningMode? defaultVersioningMode = null, // Looked up from main config
bool defaultTrackMergeTarget = false,
string defaultTagNumberPattern = null,
bool isDevelop = false,
bool tracksReleaseBranches = false,
bool isReleaseBranch = false,
bool isMainline = false)
{
Expand All @@ -174,7 +175,7 @@ public static void ApplyBranchDefaults(Config config,
branchConfig.PreventIncrementOfMergedBranchVersion = branchConfig.PreventIncrementOfMergedBranchVersion ?? defaultPreventIncrement;
branchConfig.TrackMergeTarget = branchConfig.TrackMergeTarget ?? defaultTrackMergeTarget;
branchConfig.VersioningMode = branchConfig.VersioningMode ?? defaultVersioningMode ?? config.VersioningMode;
branchConfig.IsDevelop = branchConfig.IsDevelop ?? isDevelop;
branchConfig.TracksReleaseBranches = branchConfig.TracksReleaseBranches ?? tracksReleaseBranches;
branchConfig.IsReleaseBranch = branchConfig.IsReleaseBranch ?? isReleaseBranch;
branchConfig.IsMainline = branchConfig.IsMainline ?? isMainline;
}
Expand Down
Loading