Skip to content

Feature branch does not pick up version #1004

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

Closed
Closed
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 @@ -144,23 +144,23 @@ 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
releases?[/-]:
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: false
tracks-release-branches: false
is-release-branch: true
features?[/-]:
mode: ContinuousDelivery
tag: useBranchName
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|pull\-requests|pr)[/-]:
mode: ContinuousDelivery
Expand All @@ -169,31 +169,31 @@ 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(es)?[/-]:
mode: ContinuousDelivery
tag: beta
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[/-]:
mode: ContinuousDelivery
tag: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: false
tracks-release-branches: false
is-release-branch: false
dev(elop)?(ment)?$:
mode: ContinuousDeployment
tag: unstable
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 @@ -252,7 +252,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 @@ -17,7 +17,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
is-mainline: true
releases?[/-]:
Expand All @@ -26,7 +26,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
is-mainline: false
features?[/-]:
Expand All @@ -35,7 +35,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
is-mainline: false
(pull|pull\-requests|pr)[/-]:
Expand All @@ -45,7 +45,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
is-mainline: false
hotfix(es)?[/-]:
Expand All @@ -54,7 +54,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
is-mainline: false
support[/-]:
Expand All @@ -63,7 +63,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
is-mainline: true
dev(elop)?(ment)?$:
Expand All @@ -72,7 +72,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
is-mainline: false
ignore:
Expand Down
21 changes: 20 additions & 1 deletion src/GitVersionCore.Tests/ConfigProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void CanReadDocumentAndMigrate()
tag: dev
release[/-]:
mode: continuousDeployment
tag: rc
tag: rc
";
SetupConfigFileContent(text);

Expand Down Expand Up @@ -308,4 +308,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,49 @@ public void BranchCreatedAfterFinishReleaseShouldInheritAndIncrementFromLastMast
fixture.AssertFullSemver("0.3.0-TEST-1.1+2");
}
}
}

[Test]
public void PickUpVersionFromMasterMarkedWithIsDevelop()
{
var config = new Config
{
VersioningMode = VersioningMode.ContinuousDelivery,
Branches = new Dictionary<string, BranchConfig>
{
{
"master", new BranchConfig()
{
Tag = "pre",
TracksReleaseBranches = true,
}
},
{
"releases?[/-]", new BranchConfig()
{
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
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
16 changes: 7 additions & 9 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 All @@ -18,7 +16,7 @@ public static KeyValuePair<string, BranchConfig> GetBranchConfiguration(Commit c
if (matchingBranches.Length == 0)
{
var branchConfig = new BranchConfig();
ConfigurationProvider.ApplyBranchDefaults(config, branchConfig);
ConfigurationProvider.ApplyBranchDefaults(config, branchConfig, tracksReleaseBranches: true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is right actually as @DanielRose says. The default shouldn't be to track release branches because there could be feature branches off support branches or any number of other scenarios.

return new KeyValuePair<string, BranchConfig>(string.Empty, branchConfig);
}
if (matchingBranches.Length == 1)
Expand All @@ -44,12 +42,12 @@ static KeyValuePair<string, BranchConfig>[] LookupBranchConfiguration([NotNull]
{
throw new ArgumentNullException("config");
}

if (currentBranch == null)
{
throw new ArgumentNullException("currentBranch");
}

return config.Branches.Where(b => Regex.IsMatch(currentBranch.FriendlyName, "^" + b.Key, RegexOptions.IgnoreCase)).ToArray();
}

Expand Down Expand Up @@ -116,7 +114,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 @@ -144,7 +142,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 @@ -17,7 +17,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 @@ -42,12 +42,12 @@ 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 = "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
10 changes: 5 additions & 5 deletions src/GitVersionCore/Configuration/ConfigurationProvider.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace GitVersion
{
using System;
using GitVersion.Configuration.Init.Wizard;
using GitVersion.Helpers;
using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -106,10 +106,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)
{
ApplyBranchDefaults(config, branchConfig.Value);
Expand Down Expand Up @@ -165,7 +165,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 @@ -175,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