-
Notifications
You must be signed in to change notification settings - Fork 654
Ignore version numbers in branch names that are not release branches. #1541
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
asbjornu
merged 13 commits into
GitTools:master
from
bert2:bugfix/issue-1536-ignore-versions-in-branch-names
Feb 15, 2019
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
854cb55
Ignore unrelated version numbers in branch names that are not release
bert2 cd78046
extract duplication from the strategies
bert2 245c9fa
Merge branch 'master' into bugfix/issue-1536-ignore-versions-in-branc…
bert2 ccd0330
Merge remote-tracking branch 'upstream/master' into bugfix/issue-1536…
bert2 9fd376c
take versions from branch names only when they are release (remove co…
bert2 1a572aa
remove namespace of new mock types
bert2 ad59a80
only consider origin a remote that can have release branches
bert2 0ba2eda
Merge branch 'master' into bugfix/issue-1536-ignore-versions-in-branc…
bert2 692c35a
Merge branch 'master' into bugfix/issue-1536-ignore-versions-in-branc…
bert2 1c84f2d
fix: takes version from the current branch name even when its not fro…
bert2 c515c25
tests if custom remotes are ignored when taking version from current …
bert2 ec5d880
integration test ignoring of versions from branch names in custom rem…
bert2 426de26
Merge branch 'master' into bugfix/issue-1536-ignore-versions-in-branc…
asbjornu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/GitVersionCore.Tests/IntegrationTests/VersionInCurrentBranchNameScenarios.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
namespace GitVersionCore.Tests.IntegrationTests | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using GitTools.Testing; | ||
|
||
using GitVersion; | ||
|
||
using GitVersionCore.Tests; | ||
|
||
using LibGit2Sharp; | ||
|
||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class VersionInCurrentBranchNameScenarios : TestBase | ||
{ | ||
[Test] | ||
public void TakesVersionFromNameOfReleaseBranch() | ||
{ | ||
using (var fixture = new BaseGitFlowRepositoryFixture("1.0.0")) | ||
{ | ||
fixture.BranchTo("release/2.0.0"); | ||
|
||
fixture.AssertFullSemver("2.0.0-beta.1+0"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void DoesNotTakeVersionFromNameOfNonReleaseBranch() | ||
{ | ||
using (var fixture = new BaseGitFlowRepositoryFixture("1.0.0")) | ||
{ | ||
fixture.BranchTo("feature/upgrade-power-level-to-9000.0.1"); | ||
|
||
fixture.AssertFullSemver("1.1.0-upgrade-power-level-to-9000-0-1.1+1"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TakesVersionFromNameOfBranchThatIsReleaseByConfig() | ||
{ | ||
var config = new Config | ||
{ | ||
Branches = new Dictionary<string, BranchConfig> { { "support", new BranchConfig { IsReleaseBranch = true } } } | ||
}; | ||
|
||
using (var fixture = new BaseGitFlowRepositoryFixture("1.0.0")) | ||
{ | ||
fixture.BranchTo("support/2.0.0"); | ||
|
||
fixture.AssertFullSemver(config, "2.0.0+1"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TakesVersionFromNameOfRemoteReleaseBranchInOrigin() | ||
{ | ||
using (var fixture = new RemoteRepositoryFixture()) | ||
{ | ||
fixture.BranchTo("release/2.0.0"); | ||
fixture.MakeACommit(); | ||
Commands.Fetch((Repository)fixture.LocalRepositoryFixture.Repository, fixture.LocalRepositoryFixture.Repository.Network.Remotes.First().Name, new string[0], new FetchOptions(), null); | ||
|
||
fixture.LocalRepositoryFixture.Checkout("origin/release/2.0.0"); | ||
|
||
fixture.LocalRepositoryFixture.AssertFullSemver("2.0.0-beta.1+1"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void DoesNotTakeVersionFromNameOfRemoteReleaseBranchInCustomRemote() | ||
{ | ||
using (var fixture = new RemoteRepositoryFixture()) | ||
{ | ||
fixture.LocalRepositoryFixture.Repository.Network.Remotes.Rename("origin", "upstream"); | ||
fixture.BranchTo("release/2.0.0"); | ||
fixture.MakeACommit(); | ||
Commands.Fetch((Repository)fixture.LocalRepositoryFixture.Repository, fixture.LocalRepositoryFixture.Repository.Network.Remotes.First().Name, new string[0], new FetchOptions(), null); | ||
|
||
fixture.LocalRepositoryFixture.Checkout("upstream/release/2.0.0"); | ||
|
||
fixture.LocalRepositoryFixture.AssertFullSemver("0.1.0-beta.1+5"); | ||
} | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/GitVersionCore.Tests/IntegrationTests/VersionInMergedBranchNameScenarios.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
namespace GitVersionCore.Tests.IntegrationTests | ||
{ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using GitTools.Testing; | ||
|
||
using GitVersion; | ||
|
||
using GitVersionCore.Tests; | ||
|
||
using LibGit2Sharp; | ||
|
||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class VersionInMergedBranchNameScenarios : TestBase | ||
{ | ||
[Test] | ||
public void TakesVersionFromNameOfReleaseBranch() | ||
{ | ||
using (var fixture = new BaseGitFlowRepositoryFixture("1.0.0")) | ||
{ | ||
fixture.CreateAndMergeBranchIntoDevelop("release/2.0.0"); | ||
|
||
fixture.AssertFullSemver("2.1.0-alpha.2"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void DoesNotTakeVersionFromNameOfNonReleaseBranch() | ||
{ | ||
using (var fixture = new BaseGitFlowRepositoryFixture("1.0.0")) | ||
{ | ||
fixture.CreateAndMergeBranchIntoDevelop("pull-request/improved-by-upgrading-some-lib-to-4.5.6"); | ||
fixture.CreateAndMergeBranchIntoDevelop("hotfix/downgrade-some-lib-to-3.2.1-to-avoid-breaking-changes"); | ||
|
||
fixture.AssertFullSemver("1.1.0-alpha.5"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TakesVersionFromNameOfBranchThatIsReleaseByConfig() | ||
{ | ||
var config = new Config | ||
{ | ||
Branches = new Dictionary<string, BranchConfig> { { "support", new BranchConfig { IsReleaseBranch = true } } } | ||
}; | ||
|
||
using (var fixture = new BaseGitFlowRepositoryFixture("1.0.0")) | ||
{ | ||
fixture.CreateAndMergeBranchIntoDevelop("support/2.0.0"); | ||
|
||
fixture.AssertFullSemver(config, "2.1.0-alpha.2"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void TakesVersionFromNameOfRemoteReleaseBranchInOrigin() | ||
{ | ||
using (var fixture = new RemoteRepositoryFixture()) | ||
{ | ||
fixture.BranchTo("release/2.0.0"); | ||
fixture.MakeACommit(); | ||
Commands.Fetch((Repository)fixture.LocalRepositoryFixture.Repository, fixture.LocalRepositoryFixture.Repository.Network.Remotes.First().Name, new string[0], new FetchOptions(), null); | ||
|
||
fixture.LocalRepositoryFixture.MergeNoFF("origin/release/2.0.0"); | ||
|
||
fixture.LocalRepositoryFixture.AssertFullSemver("2.0.0+0"); | ||
} | ||
} | ||
|
||
[Test] | ||
public void DoesNotTakeVersionFromNameOfRemoteReleaseBranchInCustomRemote() | ||
{ | ||
using (var fixture = new RemoteRepositoryFixture()) | ||
{ | ||
fixture.LocalRepositoryFixture.Repository.Network.Remotes.Rename("origin", "upstream"); | ||
fixture.BranchTo("release/2.0.0"); | ||
fixture.MakeACommit(); | ||
Commands.Fetch((Repository)fixture.LocalRepositoryFixture.Repository, fixture.LocalRepositoryFixture.Repository.Network.Remotes.First().Name, new string[0], new FetchOptions(), null); | ||
|
||
fixture.LocalRepositoryFixture.MergeNoFF("upstream/release/2.0.0"); | ||
|
||
fixture.LocalRepositoryFixture.AssertFullSemver("0.1.0+6"); | ||
} | ||
} | ||
} | ||
|
||
internal static class BaseGitFlowRepositoryFixtureExtensions | ||
{ | ||
public static void CreateAndMergeBranchIntoDevelop(this BaseGitFlowRepositoryFixture fixture, string branchName) | ||
{ | ||
fixture.BranchTo(branchName); | ||
fixture.MakeACommit(); | ||
fixture.Checkout("develop"); | ||
fixture.MergeNoFF(branchName); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.