Skip to content

Commit 8f3d698

Browse files
committed
Test for GitFlow vs mainline mode
1 parent 5c79c50 commit 8f3d698

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

src/GitVersionCore.Tests/IntegrationTests/MainlineDevelopmentMode.cs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,94 @@ public void VerifySupportForwardMerge()
198198
}
199199
}
200200

201+
[Test]
202+
public void VerifyDevelopTracksMasterVersion()
203+
{
204+
using (var fixture = new EmptyRepositoryFixture())
205+
{
206+
fixture.Repository.MakeACommit("1");
207+
fixture.MakeATaggedCommit("1.0.0");
208+
fixture.MakeACommit();
209+
210+
// branching increments the version
211+
fixture.BranchTo("develop");
212+
fixture.AssertFullSemver(config, "1.1.0-alpha.0");
213+
fixture.MakeACommit();
214+
fixture.AssertFullSemver(config, "1.1.0-alpha.1");
215+
216+
// merging develop into master increments minor version on master
217+
fixture.Checkout("master");
218+
fixture.MergeNoFF("develop");
219+
fixture.AssertFullSemver(config, "1.1.0");
220+
221+
// a commit on develop before the merge still has the same version number
222+
fixture.Checkout("develop");
223+
fixture.AssertFullSemver(config, "1.1.0-alpha.1");
224+
225+
// moving on to further work on develop tracks master's version from the merge
226+
fixture.MakeACommit();
227+
fixture.AssertFullSemver(config, "1.2.0-alpha.1");
228+
229+
// adding a commit to master increments patch
230+
fixture.Checkout("master");
231+
fixture.MakeACommit();
232+
fixture.AssertFullSemver(config, "1.1.1");
233+
234+
// adding a commit to master doesn't change develop's version
235+
fixture.Checkout("develop");
236+
fixture.AssertFullSemver(config, "1.2.0-alpha.1");
237+
}
238+
}
239+
240+
[Test]
241+
public void VerifyDevelopFeatureTracksMasterVersion()
242+
{
243+
using (var fixture = new EmptyRepositoryFixture())
244+
{
245+
fixture.Repository.MakeACommit("1");
246+
fixture.MakeATaggedCommit("1.0.0");
247+
fixture.MakeACommit();
248+
249+
// branching increments the version
250+
fixture.BranchTo("develop");
251+
fixture.AssertFullSemver(config, "1.1.0-alpha.0");
252+
fixture.MakeACommit();
253+
fixture.AssertFullSemver(config, "1.1.0-alpha.1");
254+
255+
// merging develop into master increments minor version on master
256+
fixture.Checkout("master");
257+
fixture.MergeNoFF("develop");
258+
fixture.AssertFullSemver(config, "1.1.0");
259+
260+
// a commit on develop before the merge still has the same version number
261+
fixture.Checkout("develop");
262+
fixture.AssertFullSemver(config, "1.1.0-alpha.1");
263+
264+
// a branch from develop before the merge tracks the pre-merge version from master
265+
// (note: the commit on develop looks like a commit to this branch, thus the .1)
266+
fixture.BranchTo("feature/foo");
267+
fixture.AssertFullSemver(config, "1.0.2-foo.1");
268+
269+
// further work on the branch tracks the merged version from master
270+
fixture.MakeACommit();
271+
fixture.AssertFullSemver(config, "1.1.1-foo.1");
272+
273+
// adding a commit to master increments patch
274+
fixture.Checkout("master");
275+
fixture.MakeACommit();
276+
fixture.AssertFullSemver(config, "1.1.1");
277+
278+
// adding a commit to master doesn't change the feature's version
279+
fixture.Checkout("feature/foo");
280+
fixture.AssertFullSemver(config, "1.1.1-foo.1");
281+
282+
// merging the feature to develop increments develop
283+
fixture.Checkout("develop");
284+
fixture.MergeNoFF("feature/foo");
285+
fixture.AssertFullSemver(config, "1.2.0-alpha.2");
286+
}
287+
}
288+
201289
[Test]
202290
public void VerifyMergingMasterToFeatureDoesNotCauseBranchCommitsToIncrementVersion()
203291
{

0 commit comments

Comments
 (0)