Skip to content

Bump develop when release branch created #759

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
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
4 changes: 4 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ The global configuration options are:

- **`commit-message-incrementing:`** Sets whether it should be possible to increment the version with special syntax in the commit message. See the `*-version-bump-message` options above for details on the syntax. Default set to `Enabled`; set to `Disabled` to disable.

- **`is-develop:`** Indicates this branch config represents develop in GitFlow

**`is-release-branch:`** Indicates this branch config represents a release branch in GitFlow

## Branch configuration

Then we have branch specific configuration, which looks something like this:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ branches:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-release-branch: true
features?[/-]:
mode: ContinuousDelivery
tag: useBranchName
Expand Down Expand Up @@ -49,7 +50,8 @@ branches:
track-merge-target: false
dev(elop)?(ment)?$:
mode: ContinuousDeployment
tag: unstable
tag: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
is-develop: true
4 changes: 2 additions & 2 deletions src/GitVersionCore.Tests/ConfigProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void CanProvideConfigForNewBranch()
tag: bugfix";
SetupConfigFileContent(text);
var config = ConfigurationProvider.Provide(repoPath, fileSystem);

config.Branches["bug[/-]"].Tag.ShouldBe("bugfix");
}

Expand Down Expand Up @@ -162,7 +162,7 @@ public void CanReadDefaultDocument()
var config = ConfigurationProvider.Provide(repoPath, fileSystem);
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinorPatch);
config.AssemblyInformationalFormat.ShouldBe(null);
config.Branches["dev(elop)?(ment)?$"].Tag.ShouldBe("unstable");
config.Branches["dev(elop)?(ment)?$"].Tag.ShouldBe("alpha");
config.Branches["releases?[/-]"].Tag.ShouldBe("beta");
config.TagPrefix.ShouldBe(ConfigurationProvider.DefaultTagPrefix);
config.NextVersion.ShouldBe(null);
Expand Down
10 changes: 7 additions & 3 deletions src/GitVersionCore.Tests/GitToolsTestingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ public static Config ApplyDefaults(this Config config)
return config;
}

public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true)
public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration = null, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true)
{
ConfigurationProvider.ApplyDefaultsTo(configuration);
if (configuration == null)
{
configuration = new Config();
ConfigurationProvider.ApplyDefaultsTo(configuration);
}
var gitVersionContext = new GitVersionContext(repository ?? fixture.Repository, configuration, isForTrackedBranchOnly, commitId);
var executeGitVersion = ExecuteGitVersion(gitVersionContext);
var variables = VariableProvider.GetVariablesFor(executeGitVersion, gitVersionContext.Configuration, gitVersionContext.IsCurrentCommitTagged);
Expand Down Expand Up @@ -54,7 +58,7 @@ public static void AssertFullSemver(this RepositoryFixtureBase fixture, Config c
}
if (commitId == null)
{
fixture.SequenceDiagram.NoteOver(fullSemver, fixture.Repository.Head.FriendlyName, color: "#D3D3D3");
fixture.SequenceDiagram.NoteOver(fullSemver, fixture.Repository.Head.FriendlyName, color: "#D3D3D3");
}
}

Expand Down
40 changes: 32 additions & 8 deletions src/GitVersionCore.Tests/IntegrationTests/DevelopScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void WhenDevelopHasMultipleCommits_SpecifyExistingCommitId()
fixture.Repository.MakeACommit();
fixture.Repository.MakeACommit();

fixture.AssertFullSemver("1.1.0-unstable.3", commitId: thirdCommit.Sha);
fixture.AssertFullSemver("1.1.0-alpha.3", commitId: thirdCommit.Sha);
}
}

Expand All @@ -39,7 +39,7 @@ public void WhenDevelopHasMultipleCommits_SpecifyNonExistingCommitId()
fixture.Repository.MakeACommit();
fixture.Repository.MakeACommit();

fixture.AssertFullSemver("1.1.0-unstable.5", commitId: "nonexistingcommitid");
fixture.AssertFullSemver("1.1.0-alpha.5", commitId: "nonexistingcommitid");
}
}

Expand All @@ -61,10 +61,11 @@ public void CanChangeDevelopTagViaConfig()
{
Branches =
{
{"dev(elop)?(ment)?$", new BranchConfig
{
Tag = "alpha"
}
"dev(elop)?(ment)?$", new BranchConfig
{
Tag = "alpha"
}
}
}
};
Expand Down Expand Up @@ -97,7 +98,7 @@ public void WhenDevelopBranchedFromMaster_MinorIsIncreased()
fixture.Repository.MakeATaggedCommit("1.0.0");
fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
fixture.Repository.MakeACommit();
fixture.AssertFullSemver("1.1.0-unstable.1");
fixture.AssertFullSemver("1.1.0-alpha.1");
}
}

Expand All @@ -116,7 +117,7 @@ public void MergingReleaseBranchBackIntoDevelopWithMergingToMaster_DoesBumpDevel

fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("release-2.0.0", Generate.SignatureNow());
fixture.AssertFullSemver("2.1.0-unstable.0");
fixture.AssertFullSemver("2.1.0-alpha.2");
}
}

Expand Down Expand Up @@ -154,7 +155,30 @@ public void WhenDevelopBranchedFromMasterDetachedHead_MinorIsIncreased()
var commit = fixture.Repository.Head.Tip;
fixture.Repository.MakeACommit();
fixture.Repository.Checkout(commit);
fixture.AssertFullSemver("1.1.0-unstable.1");
fixture.AssertFullSemver("1.1.0-alpha.1");
}
}

[Test]
public void InheritVersionFromReleaseBranch()
{
using (var fixture = new EmptyRepositoryFixture())
{
fixture.MakeATaggedCommit("1.0.0");
fixture.BranchTo("develop");
fixture.MakeACommit();
fixture.BranchTo("release/2.0.0");
fixture.MakeACommit();
fixture.MakeACommit();
fixture.Checkout("develop");
fixture.AssertFullSemver("2.1.0-alpha.0");
fixture.MakeACommit();
fixture.AssertFullSemver("2.1.0-alpha.1");
fixture.MergeNoFF("release/2.0.0");
fixture.AssertFullSemver("2.1.0-alpha.4");
fixture.BranchTo("feature/MyFeature");
fixture.MakeACommit();
fixture.AssertFullSemver("2.1.0-MyFeature.1+1");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void GitFlowFeatureBranch()

// Branch to develop
fixture.MakeACommit();
fixture.AssertFullSemver("1.3.0-unstable.1");
fixture.AssertFullSemver("1.3.0-alpha.1");

// Open Pull Request
fixture.BranchTo("feature/myfeature", "feature");
Expand All @@ -37,7 +37,7 @@ public void GitFlowFeatureBranch()
fixture.SequenceDiagram.Destroy("feature/myfeature");
fixture.SequenceDiagram.NoteOver("Feature branches should\r\n" +
"be deleted once merged", "feature/myfeature");
fixture.AssertFullSemver("1.3.0-unstable.3");
fixture.AssertFullSemver("1.3.0-alpha.3");
}
}

Expand All @@ -56,7 +56,7 @@ public void GitFlowPullRequestBranch()

// Branch to develop
fixture.MakeACommit();
fixture.AssertFullSemver("1.3.0-unstable.1");
fixture.AssertFullSemver("1.3.0-alpha.1");

// Open Pull Request
fixture.BranchTo("pull/2/merge", "pr");
Expand All @@ -71,7 +71,7 @@ public void GitFlowPullRequestBranch()
fixture.SequenceDiagram.Destroy("pull/2/merge");
fixture.SequenceDiagram.NoteOver("Feature branches/pr's should\r\n" +
"be deleted once merged", "pull/2/merge");
fixture.AssertFullSemver("1.3.0-unstable.3");
fixture.AssertFullSemver("1.3.0-alpha.3");
}
}

Expand Down Expand Up @@ -129,7 +129,7 @@ public void GitFlowMinorRelease()
// Make another commit on develop
fixture.Checkout("develop");
fixture.MakeACommit();
fixture.AssertFullSemver("1.3.0-unstable.2");
fixture.AssertFullSemver("1.4.0-alpha.1");

// Make a commit to release-1.3.0
fixture.Checkout("release/1.3.0");
Expand Down Expand Up @@ -158,7 +158,7 @@ public void GitFlowMinorRelease()

// Not 0 for commit count as we can't know the increment rules of the merged branch
fixture.Checkout("develop");
fixture.AssertFullSemver("1.4.0-unstable.2");
fixture.AssertFullSemver("1.4.0-alpha.4");
}
}

Expand All @@ -185,7 +185,7 @@ public void GitFlowMajorRelease()
// Make another commit on develop
fixture.Checkout("develop");
fixture.MakeACommit();
fixture.AssertFullSemver("1.4.0-unstable.2");
fixture.AssertFullSemver("2.1.0-alpha.1");

// Make a commit to release-2.0.0
fixture.Checkout("release/2.0.0");
Expand Down Expand Up @@ -215,7 +215,7 @@ public void GitFlowMajorRelease()

// Not 0 for commit count as we can't know the increment rules of the merged branch
fixture.Checkout("develop");
fixture.AssertFullSemver("2.1.0-unstable.2");
fixture.AssertFullSemver("2.1.0-alpha.4");
}
}

Expand Down Expand Up @@ -394,7 +394,7 @@ public void GitHubFlowMajorRelease()
fixture.AssertFullSemver("2.0.0-beta.1");

// test that the CommitsSinceVersionSource should still return commit count
var version = fixture.GetVersion(new Config());
var version = fixture.GetVersion();
version.CommitsSinceVersionSource.ShouldBe("2");

// Make a commit after a tag should bump up the beta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public void PatchLatestReleaseExample()

// Verify develop version
fixture.Repository.Checkout("develop");
fixture.AssertFullSemver("1.3.0-unstable.1");
fixture.AssertFullSemver("1.3.0-alpha.1");

fixture.Repository.MergeNoFF("hotfix-1.2.1", Generate.SignatureNow());
fixture.AssertFullSemver("1.3.0-unstable.5");
fixture.AssertFullSemver("1.3.0-alpha.5");
}
}

Expand Down Expand Up @@ -118,9 +118,9 @@ public void PatchOlderReleaseExample()

// Verify develop version
fixture.Repository.Checkout("develop");
fixture.AssertFullSemver("2.1.0-unstable.1");
fixture.AssertFullSemver("2.1.0-alpha.1");
fixture.Repository.MergeNoFF("support-1.1", Generate.SignatureNow());
fixture.AssertFullSemver("2.1.0-unstable.7");
fixture.AssertFullSemver("2.1.0-alpha.7");
}
}
}
4 changes: 2 additions & 2 deletions src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void AllowNotHavingMaster()
fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
fixture.Repository.Branches.Remove(fixture.Repository.Branches["master"]);

fixture.AssertFullSemver("1.1.0-unstable.1");
fixture.AssertFullSemver("1.1.0-alpha.1");
}
}

Expand All @@ -60,7 +60,7 @@ public void DoNotBlowUpWhenDevelopAndFeatureBranchPointAtSameCommit()
fixture.LocalRepositoryFixture.Repository.Checkout(fixture.Repository.Head.Tip);
fixture.LocalRepositoryFixture.Repository.Branches.Remove("master");
fixture.InitialiseRepo();
fixture.AssertFullSemver("1.1.0-unstable.1");
fixture.AssertFullSemver("1.1.0-alpha.1");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void NoMergeBacksToDevelopInCaseThereAreNoChangesInReleaseBranch()

fixture.Repository.Branches.Remove(releaseBranch);

fixture.AssertFullSemver("1.1.0-unstable.1");
fixture.AssertFullSemver("1.1.0-alpha.1");
}
}

Expand All @@ -48,12 +48,12 @@ public void NoMergeBacksToDevelopInCaseThereAreChangesInReleaseBranch()
// Merge to develop
fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("release/1.0.0");
fixture.AssertFullSemver("1.1.0-unstable.1");
fixture.AssertFullSemver("1.1.0-alpha.2");

fixture.Repository.MakeACommit();
fixture.Repository.Branches.Remove(releaseBranch);

fixture.AssertFullSemver("1.1.0-unstable.2");
fixture.AssertFullSemver("1.1.0-alpha.2");
}
}

Expand Down Expand Up @@ -226,7 +226,7 @@ public void WhenReleaseBranchIsMergedIntoDevelopHighestVersionIsTakenWithIt()
fixture.Repository.Checkout("develop");
fixture.Repository.MergeNoFF("release-1.0.0", Generate.SignatureNow());

fixture.AssertFullSemver("2.1.0-unstable.5");
fixture.AssertFullSemver("2.1.0-alpha.6");
}
}

Expand Down Expand Up @@ -265,7 +265,7 @@ public void WhenMergingReleaseBackToDevShouldNotResetBetaVersion()
fixture.Repository.Checkout("develop");

fixture.Repository.MakeCommits(1);
fixture.AssertFullSemver("1.1.0-unstable.1");
fixture.AssertFullSemver("1.1.0-alpha.1");

fixture.Repository.CreateBranch("release-2.0.0");
fixture.Repository.Checkout("release-2.0.0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void WhenDevelopBranchedFromMasterWithLegacyVersionTags_DevelopCanUseReac
fixture.Repository.MakeATaggedCommit("1.0.0.0");
fixture.Repository.MakeCommits(2);
fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
fixture.AssertFullSemver("1.1.0-unstable.2");
fixture.AssertFullSemver("1.1.0-alpha.2");
}
}
}
7 changes: 5 additions & 2 deletions src/GitVersionCore.Tests/TestEffectiveConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ public TestEffectiveConfiguration(
CommitMessageIncrementMode commitMessageMode = CommitMessageIncrementMode.Enabled,
int legacySemVerPadding = 4,
int buildMetaDataPadding = 4,
int commitsSinceVersionSourcePadding = 4) :
int commitsSinceVersionSourcePadding = 4,
bool isDevelop = false,
bool isRelease = false) :
base(assemblyVersioningScheme, assemblyInformationalFormat, versioningMode, gitTagPrefix, tag, nextVersion, IncrementStrategy.Patch,
branchPrefixToTrim, preventIncrementForMergedBranchVersion, tagNumberPattern, continuousDeploymentFallbackTag,
trackMergeTarget,
majorMessage, minorMessage, patchMessage,
commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding)
commitMessageMode, legacySemVerPadding, buildMetaDataPadding, commitsSinceVersionSourcePadding,
isDevelop, isRelease)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void AppliesBranchPreReleaseTag()

var version = sut.FindVersion(context);

version.ToString("f").ShouldBe("1.0.0-unstable.1+2");
version.ToString("f").ShouldBe("1.0.0-alpha.1+2");
}

[Test]
Expand Down
8 changes: 8 additions & 0 deletions src/GitVersionCore/Configuration/BranchConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public BranchConfig(BranchConfig branchConfiguration)
TagNumberPattern = branchConfiguration.TagNumberPattern;
TrackMergeTarget = branchConfiguration.TrackMergeTarget;
CommitMessageIncrementing = branchConfiguration.CommitMessageIncrementing;
IsDevelop = branchConfiguration.IsDevelop;
IsReleaseBranch = branchConfiguration.IsReleaseBranch;
}

[YamlMember(Alias = "mode")]
Expand All @@ -42,5 +44,11 @@ public BranchConfig(BranchConfig branchConfiguration)

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

[YamlMember(Alias = "is-develop")]
public bool IsDevelop { get; set; }

[YamlMember(Alias = "is-release-branch")]
public bool IsReleaseBranch { get; set; }
}
}
Loading