Skip to content

Commit fc2e75d

Browse files
committed
Integrate code review comments of reviewer asbjornu.
1 parent 7f0309b commit fc2e75d

File tree

5 files changed

+251
-159
lines changed

5 files changed

+251
-159
lines changed

BREAKING_CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
## Unreleased
22

33
* When using a commit message that matches **both** `*-version-bump-message` and `no-bump-message`, there is no increment for that commit. In other words, `no-bump-message` now takes precedence over `*-version-bump-message`.
4+
* The fallback version strategy returns always 0.0.0 and is flagged with should increment true. This gives you the version 0.1.0 on develop branch (IncrementStrategy.Minor) and 0.0.1 on main branch (IncremetnStrategy.Patch).
5+
* We have not one effected branch configuration we have one or more effected branch configurations. In case of inheriting from parent branches this gives you the possiblity to solve stupid edge cases.
6+
* The current branch (child) inherits from source branch (parent branch) if the increment strategy is set to inherit. This is highly recursive and can be configured via the configuration file.
47

58
## v5.0.0
69

src/GitVersion.Core.Tests/IntegrationTests/DevelopScenarios.cs

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,4 +457,111 @@ public void WhenPreventIncrementOfMergedBranchVersionIsSetToFalseForDevelopCommi
457457
fixture.Repository.Branches.Remove(HotfixBranch);
458458
fixture.AssertFullSemver("1.2.0-alpha.19", config);
459459
}
460+
461+
[Test]
462+
public void NextVersionShouldBeConsideredOnTheMainBranch()
463+
{
464+
using EmptyRepositoryFixture fixture = new("main");
465+
466+
var configurationBuilder = TestConfigurationBuilder.New;
467+
468+
fixture.MakeACommit();
469+
470+
// ✅ succeeds as expected
471+
fixture.AssertFullSemver("0.0.1+1", configurationBuilder.Build());
472+
473+
configurationBuilder.WithNextVersion("1.0.0");
474+
475+
// ✅ succeeds as expected
476+
fixture.AssertFullSemver("1.0.0+1", configurationBuilder.Build());
477+
478+
fixture.MakeACommit();
479+
configurationBuilder.WithNextVersion(null);
480+
481+
// ✅ succeeds as expected
482+
fixture.AssertFullSemver("0.0.1+2", configurationBuilder.Build());
483+
484+
configurationBuilder.WithNextVersion("1.0.0");
485+
486+
// ✅ succeeds as expected
487+
fixture.AssertFullSemver("1.0.0+2", configurationBuilder.Build());
488+
}
489+
490+
/// <summary>
491+
/// Prevent decrementation of versions on the develop branch #3177
492+
/// (see https://github.com/GitTools/GitVersion/discussions/3177)
493+
/// </summary>
494+
[Test]
495+
public void PreventDecrementationOfVersionsOnTheMainBranch()
496+
{
497+
using EmptyRepositoryFixture fixture = new("develop");
498+
499+
var configurationBuilder = TestConfigurationBuilder.New;
500+
501+
fixture.MakeACommit();
502+
configurationBuilder.WithNextVersion("1.0.0");
503+
504+
// now we are ready to start with the preparation of the 1.0.0 release
505+
fixture.BranchTo("release/1.0.0");
506+
fixture.MakeACommit();
507+
508+
// ✅ succeeds as expected
509+
fixture.AssertFullSemver("1.0.0-beta.1+1", configurationBuilder.Build());
510+
511+
// now we makes changes on develop that may or may not end up in the 1.0.0 release
512+
fixture.Checkout("develop");
513+
514+
// ✅ succeeds as expected
515+
fixture.AssertFullSemver("1.1.0-alpha.0", configurationBuilder.Build());
516+
517+
fixture.MakeACommit();
518+
519+
// ✅ succeeds as expected
520+
fixture.AssertFullSemver("1.1.0-alpha.1", configurationBuilder.Build());
521+
522+
// now we do the actual release of beta 1
523+
fixture.Checkout("release/1.0.0");
524+
fixture.ApplyTag("1.0.0-beta.1");
525+
526+
// ✅ succeeds as expected
527+
fixture.AssertFullSemver("1.0.0-beta.1", configurationBuilder.Build());
528+
529+
// continue with more work on develop that may or may not end up in the 1.0.0 release
530+
fixture.Checkout("develop");
531+
fixture.MakeACommit();
532+
533+
// ✅ succeeds as expected
534+
fixture.AssertFullSemver("1.1.0-alpha.2", configurationBuilder.Build());
535+
536+
fixture.MergeNoFF("release/1.0.0");
537+
538+
// ✅ succeeds as expected
539+
fixture.AssertFullSemver("1.1.0-alpha.4", configurationBuilder.Build());
540+
541+
fixture.Repository.Branches.Remove("release/1.0.0");
542+
543+
// ✅ succeeds as expected
544+
fixture.AssertFullSemver("1.1.0-alpha.4", configurationBuilder.Build());
545+
546+
fixture.Repository.Tags.Remove("1.0.0-beta.1");
547+
548+
// Merge from develop to main
549+
fixture.BranchTo("main");
550+
551+
// ❔ expected: "0.0.1+4"
552+
// This behavior needs to be changed for the git flow workflow using the track-merge-message or track-merge-target options.
553+
// [Bug] track-merge-changes produces unexpected result when combining hotfix and support branches #3052
554+
fixture.AssertFullSemver("1.0.0+4", configurationBuilder.Build());
555+
556+
configurationBuilder.WithNextVersion("1.0.0");
557+
558+
// ✅ succeeds as expected
559+
fixture.AssertFullSemver("1.0.0+4", configurationBuilder.Build());
560+
561+
// Mark this version as RTM
562+
fixture.ApplyTag("1.0.0");
563+
564+
// ✅ succeeds as expected
565+
fixture.AssertFullSemver("1.0.0", configurationBuilder.Build());
566+
}
460567
}

src/GitVersion.Core.Tests/IntegrationTests/MainScenarios.cs

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,143 @@ public void AreTagsNotAdheringToTagPrefixIgnored()
241241

242242
fixture.AssertFullSemver("0.0.1+7", config);
243243
}
244+
245+
[Test]
246+
public void NextVersionShouldBeConsideredOnTheDevelopmentBranch()
247+
{
248+
using EmptyRepositoryFixture fixture = new("develop");
249+
250+
var configurationBuilder = TestConfigurationBuilder.New;
251+
252+
fixture.MakeACommit();
253+
254+
// ✅ succeeds as expected
255+
fixture.AssertFullSemver("0.1.0-alpha.1", configurationBuilder.Build());
256+
257+
configurationBuilder.WithNextVersion("1.0.0");
258+
259+
// ✅ succeeds as expected
260+
fixture.AssertFullSemver("1.0.0-alpha.1", configurationBuilder.Build());
261+
262+
fixture.MakeACommit();
263+
configurationBuilder.WithNextVersion(null);
264+
265+
// ✅ succeeds as expected
266+
fixture.AssertFullSemver("0.1.0-alpha.2", configurationBuilder.Build());
267+
268+
configurationBuilder.WithNextVersion("1.0.0");
269+
270+
// ✅ succeeds as expected
271+
fixture.AssertFullSemver("1.0.0-alpha.2", configurationBuilder.Build());
272+
}
273+
274+
/// <summary>
275+
/// Prevent decrementation of versions on the develop branch #3177
276+
/// (see https://github.com/GitTools/GitVersion/discussions/3177)
277+
/// </summary>
278+
[Test]
279+
public void PreventDecrementationOfVersionsOnTheDevelopmentBranch()
280+
{
281+
using EmptyRepositoryFixture fixture = new("develop");
282+
283+
var configurationBuilder = TestConfigurationBuilder.New;
284+
285+
configurationBuilder.WithNextVersion("1.0.0");
286+
fixture.MakeACommit();
287+
288+
// now we are ready to start with the preparation of the 1.0.0 release
289+
fixture.BranchTo("release/1.0.0");
290+
fixture.Checkout("develop");
291+
292+
// ✅ succeeds as expected
293+
fixture.AssertFullSemver("1.1.0-alpha.0", configurationBuilder.Build());
294+
295+
fixture.Checkout("release/1.0.0");
296+
297+
// ✅ succeeds as expected
298+
fixture.AssertFullSemver("1.0.0-beta.1+0", configurationBuilder.Build());
299+
300+
// make another commit on release/1.0.0 to prepare the actual beta1 release
301+
fixture.MakeACommit();
302+
303+
// ✅ succeeds as expected
304+
fixture.AssertFullSemver("1.0.0-beta.1+1", configurationBuilder.Build());
305+
306+
// now we makes changes on develop that may or may not end up in the 1.0.0 release
307+
fixture.Checkout("develop");
308+
309+
// ✅ succeeds as expected
310+
fixture.AssertFullSemver("1.1.0-alpha.0", configurationBuilder.Build());
311+
312+
fixture.MakeACommit();
313+
314+
// ✅ succeeds as expected
315+
fixture.AssertFullSemver("1.1.0-alpha.1", configurationBuilder.Build());
316+
317+
// now we do the actual release of beta 1
318+
fixture.Checkout("release/1.0.0");
319+
fixture.ApplyTag("1.0.0-beta.1");
320+
321+
// ✅ succeeds as expected
322+
fixture.AssertFullSemver("1.0.0-beta.1", configurationBuilder.Build());
323+
324+
// continue with more work on develop that may or may not end up in the 1.0.0 release
325+
fixture.Checkout("develop");
326+
327+
// ✅ succeeds as expected
328+
fixture.AssertFullSemver("1.1.0-alpha.1", configurationBuilder.Build());
329+
330+
fixture.MakeACommit();
331+
332+
// ✅ succeeds as expected
333+
fixture.AssertFullSemver("1.1.0-alpha.2", configurationBuilder.Build());
334+
335+
// now we decide that the new on develop should be part of the beta 2 release
336+
// so we merge it into release/1.0.0 with --no-ff because it is a protected branch
337+
// but we don't do the release of beta 2 just yet
338+
fixture.Checkout("release/1.0.0");
339+
fixture.MergeNoFF("develop");
340+
341+
// ✅ succeeds as expected
342+
fixture.AssertFullSemver("1.0.0-beta.2+2", configurationBuilder.Build());
343+
344+
fixture.Checkout("develop");
345+
346+
// ✅ succeeds as expected
347+
fixture.AssertFullSemver("1.1.0-alpha.0", configurationBuilder.Build());
348+
349+
fixture.Checkout("release/1.0.0");
350+
fixture.ApplyTag("1.0.0-beta.2");
351+
352+
// ✅ succeeds as expected
353+
fixture.AssertFullSemver("1.0.0-beta.2", configurationBuilder.Build());
354+
355+
fixture.Checkout("develop");
356+
357+
// ✅ succeeds as expected
358+
fixture.AssertFullSemver("1.1.0-alpha.0", configurationBuilder.Build());
359+
360+
fixture.MergeNoFF("release/1.0.0");
361+
362+
// ✅ succeeds as expected
363+
fixture.AssertFullSemver("1.1.0-alpha.3", configurationBuilder.Build());
364+
365+
fixture.Repository.Branches.Remove("release/1.0.0");
366+
367+
// ✅ succeeds as expected
368+
fixture.AssertFullSemver("1.1.0-alpha.3", configurationBuilder.Build());
369+
370+
fixture.Repository.Tags.Remove("1.0.0-beta.1");
371+
fixture.Repository.Tags.Remove("1.0.0-beta.2");
372+
373+
// ❔ expected: "1.0.0-alpha.3"
374+
// This behavior needs to be changed for the git flow workflow using the track-merge-message or track-merge-target options.
375+
// [Bug] track-merge-changes produces unexpected result when combining hotfix and support branches #3052
376+
fixture.AssertFullSemver("1.1.0-alpha.3", configurationBuilder.Build());
377+
378+
configurationBuilder.WithNextVersion("1.1.0");
379+
380+
// ✅ succeeds as expected
381+
fixture.AssertFullSemver("1.1.0-alpha.3", configurationBuilder.Build());
382+
}
244383
}

0 commit comments

Comments
 (0)