Skip to content

Commit

Permalink
Test implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidkeshop committed Aug 11, 2023
1 parent 0449472 commit edc900e
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -585,4 +585,97 @@ public void NoBumpMessageTakesPrecedenceOverBumpMessage(string commitMessage)

fixture.AssertFullSemver("1.0.0", conventionalCommitsConfig);
}

[Test]
public void VerifyIssue3644BumpsMajorBasedOnLastTagNotTheFullHistory()
{
/*
mode: Mainline
assembly-versioning-format: '{Major}.{Minor}.{Patch}'
assembly-file-versioning-format: '{Major}.{Minor}.{Patch}.{WeightedPreReleaseNumber ?? 0}'
branches:
master:
is-mainline: true
increment: None
major:
regex: ^major[\/-]
increment: Major
source-branches: ['master']
minor:
regex: ^minor[\/-]
increment: Minor
source-branches: ['master', 'support']
patch:
regex: ^patch[\/-]
increment: Patch
source-branches: ['master', 'support']
support:
is-mainline: true
regex: ^support[/-]
tag: ''
increment: None
source-branches: ['master']
*/

var configuration = GitFlowConfigurationBuilder.New
.WithBranch(MainBranch, builder => builder
.WithVersioningMode(VersioningMode.Mainline)
.WithIncrement(IncrementStrategy.None)
.WithIsMainline(true))
.WithBranch("major", builder => builder
.WithRegularExpression("^major[\\/-]")
.WithIncrement(IncrementStrategy.Major)
.WithSourceBranches(MainBranch))
.WithBranch("minor", builder => builder
.WithRegularExpression("^minor[\\/-]")
.WithIncrement(IncrementStrategy.Minor)
.WithSourceBranches(MainBranch))
.WithBranch("patch", builder => builder
.WithRegularExpression("^patch[\\/-]")
.WithIncrement(IncrementStrategy.Patch)
.WithSourceBranches(MainBranch))
.WithBranch("support", builder => builder
.WithVersioningMode(VersioningMode.Mainline)
.WithIncrement(IncrementStrategy.None)
.WithRegularExpression("^support[\\/-]")
.WithIsMainline(true)
.WithSourceBranches(MainBranch))
.Build();

// implement history from the issue
using var fixture = new EmptyRepositoryFixture();
fixture.MakeACommit("First");
fixture.MakeACommit("New file added");
fixture.ApplyTag("v1.0.0");
fixture.MakeACommit("Merged PR 123: new feature");
fixture.ApplyTag("v2.0.2");

// three branches, three merges to main
fixture.BranchTo("minor/new-feature-1");
fixture.MakeACommit("New class added");
fixture.Checkout(MainBranch);
fixture.MergeNoFF("minor/new-feature-1");

fixture.BranchTo("minor/new-feature-2");
fixture.MakeACommit("New class added");
fixture.Checkout(MainBranch);
fixture.MergeNoFF("minor/new-feature-2");

fixture.BranchTo("minor/new-feature-3");
fixture.MakeACommit("New class added");
fixture.Checkout(MainBranch);
fixture.MergeNoFF("minor/new-feature-3");

fixture.ApplyTag("v2.1.0");

// minor branch squashed
fixture.MakeACommit("Merged PR 127: squashed feature");
fixture.ApplyTag("v2.6.0");

// let's implement a breaking change
fixture.BranchTo("major/breaking-change");
fixture.MakeACommit("Breaking change implemented");

fixture.AssertFullSemver("3.0.0-breaking-change.1", configuration);
}
}
3 changes: 2 additions & 1 deletion src/GitVersion.Testing/GitTestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public static class GitTestExtensions

public static void MergeNoFF(this IRepository repository, string branch) => MergeNoFF(repository, branch, Generate.SignatureNow());

public static void MergeNoFF(this IRepository repository, string branch, Signature sig) => repository.Merge(repository.Branches[branch], sig, new MergeOptions
public static void MergeNoFF(this IRepository repository, string branch, Signature sig) =>
repository.Merge(repository.Branches[branch], sig, new MergeOptions
{
FastForwardStrategy = FastForwardStrategy.NoFastForward
});
Expand Down

0 comments on commit edc900e

Please sign in to comment.