Skip to content

Commit

Permalink
Merge pull request #832 from JakeGinnivan/BumpDevelopWhenReleaseBranc…
Browse files Browse the repository at this point in the history
…hCreated

Bump develop when release branch created
  • Loading branch information
JakeGinnivan authored Jul 19, 2016
2 parents 35c696a + 3f6bc9e commit e1f3576
Show file tree
Hide file tree
Showing 39 changed files with 437 additions and 213 deletions.
6 changes: 5 additions & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
assembly-versioning-scheme: MajorMinorPatch
next-version: 3.4.0
branches:
master:
tag: beta
ignore:
sha: []
4 changes: 4 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ The global configuration options are:
- **`sha:`** A sequence of SHAs to be excluded from the version calculations. Useful when there is a rogue commit in history yielding a bad version.
- **`commits-before:`** Allows to setup an exclusion range. Effectively any commit < `commits-before` will be ignored.

- **`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.
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.
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.
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 @@ -16,42 +16,56 @@ branches:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: 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
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
is-release-branch: false
(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
is-develop: 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
is-release-branch: false
support[/-]:
mode: ContinuousDelivery
tag: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: false
is-release-branch: 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
is-release-branch: false
ignore:
sha: []
18 changes: 9 additions & 9 deletions src/GitVersionCore.Tests/ConfigProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,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 All @@ -242,10 +242,10 @@ public void WarnOnExistingGitVersionConfigYamlFile(string path)

var logOutput = string.Empty;
Action<string> action = info => { logOutput = info; };
Logger.SetLoggers(action, action, action);

ConfigurationProvider.Verify(workingPath, repoPath, fileSystem);

using (Logger.AddLoggersTemporarily(action, action, action))
{
ConfigurationProvider.Verify(workingPath, repoPath, fileSystem);
}
var configFileDeprecatedWarning = string.Format("{0}' is deprecated, use '{1}' instead", ConfigurationProvider.ObsoleteConfigFileName, ConfigurationProvider.DefaultConfigFileName);
logOutput.Contains(configFileDeprecatedWarning).ShouldBe(true);
}
Expand Down Expand Up @@ -289,10 +289,10 @@ public void NoWarnOnGitVersionYmlFile()

var s = string.Empty;
Action<string> action = info => { s = info; };
Logger.SetLoggers(action, action, action);

ConfigurationProvider.Provide(repoPath, fileSystem);

using (Logger.AddLoggersTemporarily(action, action, action))
{
ConfigurationProvider.Provide(repoPath, fileSystem);
}
s.Length.ShouldBe(0);
}

Expand Down
4 changes: 1 addition & 3 deletions src/GitVersionCore.Tests/ExecuteCoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,10 @@ string RepositoryScope(ExecuteCore executeCore = null, Action<EmptyRepositoryFix
Action<string> infoLogger = s =>
{
infoBuilder.AppendLine(s);
Console.WriteLine(s);
};
executeCore = executeCore ?? new ExecuteCore(fileSystem);

Logger.SetLoggers(infoLogger, Console.WriteLine, Console.WriteLine);

using (Logger.AddLoggersTemporarily(infoLogger, s => {}, s => { }))
using (var fixture = new EmptyRepositoryFixture())
{
fixture.Repository.MakeACommit();
Expand Down
12 changes: 8 additions & 4 deletions src/GitVersionCore.Tests/GitToolsTestingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,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 @@ -55,7 +59,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 All @@ -70,7 +74,7 @@ static SemanticVersion ExecuteGitVersion(GitVersionContext context)
/// </summary>
public static void InitialiseRepo(this RemoteRepositoryFixture fixture)
{
// TODO !!new GitPreparer(null, null, new Authentication(), false, fixture.LocalRepositoryFixture.RepositoryPath).Initialise(true, null);
new GitPreparer(null, null, new Authentication(), false, fixture.LocalRepositoryFixture.RepositoryPath).Initialise(true, null);
}
}
}
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+3");
}
}
}
29 changes: 18 additions & 11 deletions src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GitTools;
using System;
using GitTools;
using GitTools.Testing;
using GitVersion;
using GitVersionCore.Tests;
using NUnit.Framework;
using Shouldly;
Expand All @@ -23,7 +23,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 @@ -38,7 +38,8 @@ 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");
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
}
}

Expand All @@ -57,7 +58,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 @@ -72,7 +73,8 @@ 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");
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
}
}

Expand Down Expand Up @@ -103,6 +105,7 @@ public void GitFlowHotfixBranch()
fixture.SequenceDiagram.Destroy("hotfix/1.2.1");
fixture.SequenceDiagram.NoteOver("Hotfix branches are deleted once merged", "hotfix/1.2.1");
fixture.ApplyTag("1.2.1");
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
}
}

Expand Down Expand Up @@ -130,7 +133,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 @@ -159,7 +162,8 @@ 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");
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
}
}

Expand All @@ -186,7 +190,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 @@ -216,7 +220,8 @@ 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");
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
}
}

Expand Down Expand Up @@ -260,6 +265,7 @@ public void GitFlowSupportHotfixRelease()
fixture.AssertFullSemver("1.3.1+4");
fixture.ApplyTag("1.3.1");
fixture.AssertFullSemver("1.3.1");
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
}
}

Expand Down Expand Up @@ -304,6 +310,7 @@ public void GitFlowSupportMinorRelease()
fixture.AssertFullSemver("1.4.0+0");
fixture.ApplyTag("1.4.0");
fixture.AssertFullSemver("1.4.0");
Console.WriteLine(fixture.SequenceDiagram.GetDiagram());
}
}

Expand Down Expand Up @@ -395,7 +402,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
Loading

0 comments on commit e1f3576

Please sign in to comment.