Skip to content

Commit 049624a

Browse files
committed
Merge pull request #364 from ParticularLabs/release/3.0.0
Release/3.0.0
2 parents 8b994aa + f277ae7 commit 049624a

File tree

240 files changed

+3593
-4441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+3593
-4441
lines changed

BREAKING CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
v3.0.0
2+
- Develop no longer tracks master
3+
- NextVersion.txt has been deprecated, only GitVersion.yaml is supported
4+
- `AssemblyFileSemVer` variable removed, AssemblyVersioningScheme configuration value makes this variable obsolete
5+
- Variables `ClassicVersion` and `ClassicVersionWithTag` removed
6+
- MSBuild task arguments (AssemblyVersioningScheme, DevelopBranchTag, ReleaseBranchTag, TagPrefix, NextVersion) have been removed, use GitVersionConfig.yaml instead
7+
- GitVersionTask ReleaseDateAttribute no longer has OriginalReleaseDate

CONTRIBUTING.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Contributing to GitVersion
2+
We love contributions to get started contributing you might need:
3+
4+
- [Get started with git](http://rogerdudler.github.io/git-guide)
5+
- [How to create a pull request](https://help.github.com/articles/using-pull-requests)
6+
- [An issue to work on](https://github.com/ParticularLabs/GitVersion/labels/up-for-grabs) - We are on [Up for grabs](http://up-for-grabs.net/), our up for grabs issues are tagged `up-for-grabs`
7+
- An understanding of our [architecture](#architecture) and how [we write tests](#writing-tests)
8+
9+
Once you know how to create a pull request and have an issue to work on, just post a comment saying you will work on it.
10+
If you end up not being able to complete the task, please post another comment so others can pick it up.
11+
12+
Issues are also welcome, [failing tests](#writing-tests) are even more welcome.
13+
14+
# Architecture
15+
GitVersion has three distict steps for calculating versions in v3.0.
16+
17+
1. If the current commit is tagged, the tag is used and build metadata (Excluding commit count) is added. The other two steps will not execute
18+
2. A set of strategies are evaluated to decide on the base version and some metadata about that version.
19+
These strategies include HighestReachableTag, NextVersionInConfig, MergedBranchWithVersion, VersionInBranchName etc.
20+
3. The highest base version is selected, using that base version the new version is calculated.
21+
22+
Visually it looks something like this:
23+
![Version Calculation](http://www.plantuml.com:80/plantuml/png/fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1_0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK_7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea_0G00)
24+
25+
[Edit Diagram](http://www.plantuml.com/plantuml/form?url=http://www.plantuml.com/plantuml/png/fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1_0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK_7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea_0G00)
26+
27+
**\*** Some strategies allow the version to be incremented, others don't. More info below
28+
**+** This version is out of context with the rest of the example. It is here just to show what happens if the check is true
29+
30+
## Base Version Strategies
31+
Currently we have the following strategies
32+
33+
- `HighestTagBaseVersionStrategy` - Finds the highest reachable tag from the current branch
34+
- `VersionInBranchBaseVersionStrategy` - Extracts version information from the branch name. eg `release/3.0.0` will find `3.0.0`
35+
- `ConfigNextVersionBaseVersionStrategy` - Returns the version from the GitVersion.yaml file
36+
- `MergeMessageBaseVersionStrategy` - Finds version numbers from merge messages. eg. `Merge 'release/3.0.0' into 'master'` will return `3.0.0`
37+
- `FallbackBaseVersionStrategy` - Always returns 0.1.0 for new repositories
38+
39+
Each strategy needs to return an instance of `BaseVersion` which has the following properties
40+
41+
- `Source` - Description of the source. eg `Merge message 'Merge 'release/3.0.0' into 'master''
42+
- `ShouldIncrement` - Some strategies should have the version incremented, others do not. eg `ConfigNextVersionBaseVersionStrategy` returns false, `HighestTagBaseVersionStrategy` returns true
43+
- `SemanticVersion` - SemVer of the base version strategy
44+
- `BaseVersionSource` - Sha of the source. Commits will be counted from this Sha. Can be null (eg ConfigNextVersionBaseVersionStrategy returns null)
45+
- `BranchNameOverride` - When `useBranchNameAsTag` is used, this allows the branch name to be changed by a base version.
46+
VersionInBranchBaseVersionStrategy uses this to strip out anything before the first - or /. So `foo` ends up being evaluated as `foo`. If in doubt, just use null
47+
48+
# Writing Tests
49+
We have made it super easy to write tests in GitVersion. Most tests you are interested in are in `GitVersionCore.Tests\IntegrationTests`.
50+
51+
There is a scenario class for each type of branch. For example MasterScenarios, FeatureBranchScenarios etc.
52+
53+
## 1. Find Appropriate Scenario class
54+
Find where your issue would logically sit. Or create a new scenario class if it doesn't fit anywhere in particular.
55+
56+
## 2. Create a test method
57+
We are currently using NUnit, so just create a descriptive test method and attribute it with `[Test]`
58+
59+
## 3. Use a fixture
60+
We have a few fixtures for different scenarios.
61+
62+
- `EmptyRepositoryFixture` - Gives you an empty git repo to start with
63+
- `RemoteRepositoryFixture` - A local repo tracking a test remote repository. The remote repo is available through the `Repository` property, the local is accessible via `LocalRepository`
64+
- `BaseGitFlowRepositoryFixture` - A repo setup for GitFlow (has a develop branch checked out ready to go)
65+
66+
You can use a fixture by just `using` it. Like this
67+
``` csharp
68+
using (var fixture = new EmptyRepositoryFixture(new Config()))
69+
{
70+
}
71+
```
72+
73+
## 4. Customise config
74+
If you are using non-default configuration just modify the `Config` class before creating the fixture
75+
76+
## 5. Writing the scenario
77+
We have a number of extension method off `IRepository` to make it easy to write tests at the flow level and not worry about creating/commiting files.
78+
79+
An example test looks like this:
80+
``` csharp
81+
fixture.Repository.MakeATaggedCommit("1.0.0");
82+
fixture.Repository.CreateBranch("feature-test");
83+
fixture.Repository.Checkout("feature-test");
84+
fixture.Repository.MakeACommit();
85+
fixture.Repository.MakeCommits(4);
86+
87+
fixture.AssertFullSemver("1.0.1-test.1+5");
88+
```
89+
90+
The last line is the most important. `AssertFullSemver` will run GitVersion and assert that the full SemVer it calculates is what you expect.
91+
92+
## 6. Submit a pull request with the failing test
93+
Even better include the fix, but a failing test is a great start

GitVersion.sln

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.30723.0
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.22512.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionExe", "GitVersionExe\GitVersionExe.csproj", "{C3578A7B-09A6-4444-9383-0DEAFA4958BD}"
77
EndProject
@@ -13,6 +13,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitVersionCore.Tests", "Git
1313
EndProject
1414
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3EFFC5D6-88D0-49D9-BB53-E1B7EB49DD45}"
1515
ProjectSection(SolutionItems) = preProject
16+
BREAKING CHANGES.md = BREAKING CHANGES.md
17+
CONTRIBUTING.md = CONTRIBUTING.md
18+
GitVersionConfig.yaml = GitVersionConfig.yaml
1619
LICENSE = LICENSE
1720
README.md = README.md
1821
EndProjectSection
@@ -24,47 +27,33 @@ EndProject
2427
Global
2528
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2629
Debug|Any CPU = Debug|Any CPU
27-
Debug|x86 = Debug|x86
2830
Release|Any CPU = Release|Any CPU
29-
Release|x86 = Release|x86
3031
EndGlobalSection
3132
GlobalSection(ProjectConfigurationPlatforms) = postSolution
3233
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3334
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Debug|x86.ActiveCfg = Debug|Any CPU
3535
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
3636
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Release|Any CPU.Build.0 = Release|Any CPU
37-
{C3578A7B-09A6-4444-9383-0DEAFA4958BD}.Release|x86.ActiveCfg = Release|Any CPU
3837
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3938
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
40-
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Debug|x86.ActiveCfg = Debug|Any CPU
4139
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
4240
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|Any CPU.Build.0 = Release|Any CPU
43-
{5A86453B-96FB-4B6E-A283-225BB9F753D3}.Release|x86.ActiveCfg = Release|Any CPU
4441
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4542
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
46-
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|x86.ActiveCfg = Debug|Any CPU
4743
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
4844
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.Build.0 = Release|Any CPU
49-
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|x86.ActiveCfg = Release|Any CPU
5045
{BF905F84-382C-440D-92F5-C61108626D8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5146
{BF905F84-382C-440D-92F5-C61108626D8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
52-
{BF905F84-382C-440D-92F5-C61108626D8D}.Debug|x86.ActiveCfg = Debug|Any CPU
5347
{BF905F84-382C-440D-92F5-C61108626D8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
5448
{BF905F84-382C-440D-92F5-C61108626D8D}.Release|Any CPU.Build.0 = Release|Any CPU
55-
{BF905F84-382C-440D-92F5-C61108626D8D}.Release|x86.ActiveCfg = Release|Any CPU
5649
{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5750
{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
58-
{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}.Debug|x86.ActiveCfg = Debug|Any CPU
5951
{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
6052
{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}.Release|Any CPU.Build.0 = Release|Any CPU
61-
{F9741A0D-B9D7-4557-9A1C-A7252C1071F5}.Release|x86.ActiveCfg = Release|Any CPU
6253
{75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6354
{75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
64-
{75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Debug|x86.ActiveCfg = Debug|Any CPU
6555
{75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
6656
{75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Release|Any CPU.Build.0 = Release|Any CPU
67-
{75C2BE85-1DAF-4E34-8305-B17AFAA982A6}.Release|x86.ActiveCfg = Release|Any CPU
6857
EndGlobalSection
6958
GlobalSection(SolutionProperties) = preSolution
7059
HideSolutionNode = FALSE

GitVersion.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleMistakenCallToGetType_002E2/@EntryIndexedValue">ERROR</s:String>
5555
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PossibleNullReferenceException/@EntryIndexedValue">WARNING</s:String>
5656
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PrivateFieldCanBeConvertedToLocalVariable/@EntryIndexedValue">ERROR</s:String>
57+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentName/@EntryIndexedValue">DO_NOT_SHOW</s:String>
58+
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantArgumentNameForLiteralExpression/@EntryIndexedValue">DO_NOT_SHOW</s:String>
5759
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAssignment/@EntryIndexedValue">ERROR</s:String>
5860
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantBaseConstructorCall/@EntryIndexedValue">ERROR</s:String>
5961
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantBoolCompare/@EntryIndexedValue">ERROR</s:String>

GitVersionConfig.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
assembly-versioning-scheme: MajorMinor
2-
next-version: 2.0.1
1+
assembly-versioning-scheme: MajorMinorPatch
2+
next-version: 3.0.0

GitVersionTask.Tests/BuildServers/BuildServerBaseTests.cs renamed to GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public void BuildNumberIsFullSemVer()
2222

2323
semanticVersion.BuildMetaData.CommitDate = DateTimeOffset.Parse("2014-03-06 23:59:59Z");
2424
semanticVersion.BuildMetaData.Sha = "commitSha";
25-
new BuildServer().WriteIntegration(semanticVersion, writes.Add);
25+
var variables = VariableProvider.GetVariablesFor(semanticVersion, AssemblyVersioningScheme.MajorMinorPatch, VersioningMode.ContinuousDelivery, "ci", false);
26+
new BuildServer().WriteIntegration(writes.Add, variables);
2627

2728
writes[1].ShouldBe("1.2.3-beta.1+5");
2829
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
assembly-versioning-scheme: MajorMinorPatch
2+
mode: ContinuousDelivery
3+
tag-prefix: '[vV]'
4+
continuous-delivery-fallback-tag: ci
5+
branches:
6+
master:
7+
tag:
8+
increment: Patch
9+
preventIncrementOfMergedBranchVersion: true
10+
release[/-]:
11+
tag: beta
12+
feature[/-]:
13+
tag: useBranchName
14+
increment: Inherit
15+
hotfix[/-]:
16+
tag: beta
17+
support[/-]:
18+
tag:
19+
increment: Patch
20+
preventIncrementOfMergedBranchVersion: true
21+
develop:
22+
mode: ContinuousDeployment
23+
tag: unstable
24+
increment: Minor
25+
(pull|pull\-requests|pr)[/-]:
26+
tag: PullRequest
27+
increment: Inherit
28+
tagNumberPattern: '[/-](?<number>\d+)[-/]'

0 commit comments

Comments
 (0)