Skip to content

Commit dbc14d5

Browse files
committed
Merge pull request #502 from JakeGinnivan/DocsUpdate
Docs update
2 parents 2705108 + d29f898 commit dbc14d5

27 files changed

+633
-224
lines changed

BREAKING CHANGES.md

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

CONTRIBUTING.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,23 @@ We love contributions to get started contributing you might need:
66
- [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`
77
- An understanding of our [architecture](#architecture) and how [we write tests](#writing-tests)
88

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.
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.
1010
If you end up not being able to complete the task, please post another comment so others can pick it up.
1111

12-
Issues are also welcome, [failing tests](#writing-tests) are even more welcome.
12+
Issues are also welcome, [failing tests](#writing-tests) are even more welcome.
13+
14+
# Contribution Guidelines
15+
- Try to use feature branches rather than developing on master
16+
- Please include tests covering the change
17+
- The docs are now stored in the repository under the `Docs` folder, please include documentation updates with your PR
1318

1419
# Architecture
1520
GitVersion has three distict steps for calculating versions in v3.0.
1621

1722
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.
23+
2. A set of strategies are evaluated to decide on the base version and some metadata about that version.
1924
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.
25+
3. The highest base version is selected, using that base version the new version is calculated.
2126

2227
Visually it looks something like this:
2328
![Version Calculation](http://www.plantuml.com:80/plantuml/png/fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1_0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK_7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea_0G00)
@@ -46,7 +51,7 @@ Each strategy needs to return an instance of `BaseVersion` which has the followi
4651
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
4752

4853
# 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`.
54+
We have made it super easy to write tests in GitVersion. Most tests you are interested in are in `GitVersionCore.Tests\IntegrationTests`.
5055

5156
There is a scenario class for each type of branch. For example MasterScenarios, FeatureBranchScenarios etc.
5257

@@ -57,7 +62,7 @@ Find where your issue would logically sit. Or create a new scenario class if it
5762
We are currently using NUnit, so just create a descriptive test method and attribute it with `[Test]`
5863

5964
## 3. Use a fixture
60-
We have a few fixtures for different scenarios.
65+
We have a few fixtures for different scenarios.
6166

6267
- `EmptyRepositoryFixture` - Gives you an empty git repo to start with
6368
- `RemoteRepositoryFixture` - A local repo tracking a test remote repository. The remote repo is available through the `Repository` property, the local is accessible via `LocalRepository`
@@ -90,4 +95,4 @@ fixture.AssertFullSemver("1.0.1-test.1+5");
9095
The last line is the most important. `AssertFullSemver` will run GitVersion and assert that the full SemVer it calculates is what you expect.
9196

9297
## 6. Submit a pull request with the failing test
93-
Even better include the fix, but a failing test is a great start
98+
Even better include the fix, but a failing test is a great start
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#GitFlow
2+
GitFlow allows more structured releases, and GitVersion will derive sensible SemVer compatible versions from this structure.
3+
4+
### Assumptions:
5+
6+
* Using [GitFlow branching model](http://nvie.com/git-model/) which always has a master and a develop branch
7+
* Following [Semantic Versioning](http://semver.org/)
8+
* Planned releases (bumps in major or minor) are done on release branches prefixed with release-. Eg: release-4.1 (or release-4.1.0)
9+
* Hotfixes are prefixed with hotfix- Eg. hotfix-4.0.4
10+
* The original GitFlow model (http://nvie.com/posts/a-successful-git-branching-model/) specifies branches with a "-" separator while the git flow extensions (https://github.com/nvie/gitflow) default to a "/" separator. Either work with GitVersion.
11+
* Tags are used on the master branch and reflects the SemVer of each stable release eg 3.3.8 , 4.0.0, etc
12+
* Tags can also be used to override versions while we transition repositories over to GitVersion
13+
* Using a build server with multi-branch building enabled eg TeamCity 8
14+
15+
### How Branches are handled
16+
17+
The descriptions of how commits and branches are versioned can be considered a type of pseudopod. With that in mind there are a few common "variables" that we will refer to:
18+
19+
* `targetBranch` => the branch we are targeting
20+
* `targetCommit` => the commit we are targeting on `targetbranch`
21+
22+
#### Master branch
23+
24+
Commits on master will always be a merge commit (Either from a `hotfix` or a `release` branch) or a tag. As such we can simply take the commit message or tag message.
25+
26+
If we try to build from a commit that is no merge and no tag then assume `0.1.0`
27+
28+
`mergeVersion` => the SemVer extracted from `targetCommit.Message`
29+
30+
* major: `mergeVersion.Major`
31+
* minor: `mergeVersion.Minor`
32+
* patch: `mergeVersion.Patch`
33+
* pre-release: 0 (perhaps count ahead commits later)
34+
* stability: final
35+
36+
Optional Tags (only when transitioning existing repository):
37+
* TagOnHeadCommit.Name={semver} => overrides the version to be {semver}
38+
39+
Long version:
40+
41+
{major}.{minor}.{patch} Sha:'{sha}'
42+
1.2.3 Sha:'a682956dccae752aa24597a0f5cd939f93614509'
43+
44+
#### Develop branch
45+
46+
`targetCommitDate` => the date of the `targetCommit`
47+
`masterVersionCommit` => the first version (merge commit or SemVer tag) on `master` that is older than the `targetCommitDate`
48+
`masterMergeVersion` => the SemVer extracted from `masterVersionCommit.Message`
49+
50+
* major: `masterMergeVersion.Major`
51+
* minor: `masterMergeVersion.Minor + 1` (0 if the override above is used)
52+
* patch: 0
53+
* pre-release: `unstable{n}` where n = how many commits `develop` is in front of `masterVersionCommit.Date` ('0' padded to 4 characters)
54+
55+
Long version:
56+
57+
{major}.{minor}.{patch}-{pre-release} Branch:'{branchName}' Sha:'{sha}'
58+
1.2.3-unstable645 Branch:'develop' Sha:'a682956dccae752aa24597a0f5cd939f93614509'
59+
60+
#### Hotfix branches
61+
62+
Named: `hotfix-{versionNumber}` eg `hotfix-1.2`
63+
64+
`branchVersion` => the SemVer extracted from `targetBranch.Name`
65+
66+
* major: `mergeVersion.Major`
67+
* minor: `mergeVersion.Minor`
68+
* patch: `mergeVersion.Patch`
69+
* pre-release: `beta{n}` where n = number of commits on branch ('0' padded to 4 characters)
70+
71+
Long version:
72+
73+
{major}.{minor}.{patch}-{pre-release} Branch:'{branchName}' Sha:'{sha}'
74+
1.2.3-beta645 Branch:'hotfix-foo' Sha:'a682956dccae752aa24597a0f5cd939f93614509'
75+
76+
#### Release branches
77+
78+
* May branch off from: develop
79+
* Must merge back into: develop and master
80+
* Branch naming convention: `release-{n}` eg `release-1.2`
81+
82+
`releaseVersion` => the SemVer extracted from `targetBranch.Name`
83+
`releaseTag` => the first version tag placed on the branch. Note that at least one version tag is required on the branch. The recommended initial tag is `{releaseVersion}.0-alpha1`. So for a branch named `release-1.2` the recommended tag would be `1.2.0-alpha1`
84+
85+
* major: `mergeVersion.Major`
86+
* minor: `mergeVersion.Minor`
87+
* patch: 0
88+
* pre-release: `{releaseTag.preRelease}.{n}` where n = 1 + the number of commits since `releaseTag`.
89+
90+
So on a branch named `release-1.2` with a tag `1.2.0-alpha1` and 4 commits after that tag the version would be `1.2.0-alpha1.4`
91+
92+
Long version:
93+
94+
{major}.{minor}.{patch}-{pre-release} Branch:'{branchName}' Sha:'{sha}'
95+
1.2.3-alpha2.4 Branch:'release-1.2' Sha:'a682956dccae752aa24597a0f5cd939f93614509'
96+
1.2.3-rc2 Branch:'release-1.2' Sha:'a682956dccae752aa24597a0f5cd939f93614509'
97+
98+
#### Feature branches
99+
100+
May branch off from: `develop`
101+
Must merge back into: `develop`
102+
Branch naming convention: anything except `master`, `develop`, `release-{n}`, or `hotfix-{n}`.
103+
104+
TODO: feature branches cannot start with a SemVer. to stop people from create branches named like "4.0.3"
105+
106+
* major: `masterMergeVersion.Major`
107+
* minor: `masterMergeVersion.Minor + 1` (0 if the override above is used)
108+
* patch: 0
109+
* pre-release: `unstable.feature-{n}` where n = First 8 characters of the commit SHA of the first commit
110+
111+
112+
Long version:
113+
114+
{major}.{minor}.{patch}-{pre-release} Branch:'{branchName}' Sha:'{sha}'
115+
1.2.3-unstable.feature-a682956d Branch:'feature1' Sha:'a682956dccae752aa24597a0f5cd939f93614509'
116+
117+
#### Pull-request branches
118+
119+
May branch off from: `develop`
120+
Must merge back into: `develop`
121+
Branch naming convention: anything except `master`, `develop`, `release-{n}`, or `hotfix-{n}`. Canonical branch name contains `/pull/`.
122+
123+
* major: `masterMergeVersion.Major`
124+
* minor: `masterMergeVersion.Minor + 1` (0 if the override above is used)
125+
* patch: 0
126+
* pre-release: `unstable.pull{n}` where n = the pull request number ('0' padded to 4 characters)
127+
128+
### Nightly Builds
129+
130+
**develop**, **feature** and **pull-request** builds are considered nightly builds and as such are not in strict adherence to SemVer.
131+
132+
## Release Candidates
133+
134+
How do we do release candidates?? Perhaps tag a release branch and then count commits forward from the tag to get RC1, RC2 etc??

Docs/branchingStrategies/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This folder contains notes about different branching strategies and how they work in GitVersion

Docs/buildServerSetup/appVeyor.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# AppVeyor Setup
2+
AppVeyor is the first build server which has a setup helper built into `GitVersion init`.
3+
4+
1. Run `GitVersion init`
5+
2. Choose `Setup build scripts` (currently option 7, but that could change)
6+
3. Choose `AppVeyor`
7+
4. Follow the prompts to generate an appveyor.yml file which works nicely with GitVersion
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Dynamic repositories
2+
GitVersion.exe requires access to the Git repository in order to do / infer all the lovely things that it does.
3+
4+
Well maybe that's not so much of a revelation..
5+
6+
_But did you know_ that in some circumstances, you may find that when your code is built, the build process isn't aware of the Git repository at all - i.e _there is no Git Repository available locally to the build!_
7+
8+
For an example of one such circumstance, you can have a read about [Team City's checkout mode: Automatically on Server](https://confluence.jetbrains.com/display/TCD7/VCS+Checkout+Mode)
9+
10+
So `how is GitVersion meant to work in that scenario?` - well it needs to be able to obtain a copy of the Git repo on the fly and not rely on the build system making one locally available..
11+
12+
Enter: **Dynamically Obtained Repo's**
13+
14+
## Tell GitVersion.exe how to obtain your repository
15+
16+
Unless you tell GitVersion.exe how to obtain the Git repository, it will assume that the Git repository is already available locally to the process - i.e. it will assume there is already a ".git" folder present, and it will use it.
17+
18+
To tell GitVersion.exe to obtain the repository on the fly, you need to call `GitVersion.exe` with the following arguments:
19+
20+
* /url [the url of your git repo]
21+
* /u [authentication username]
22+
* /p [authentication password]
23+
* /b [branch name]
24+
* /c [commit id]
25+
26+
Please note that these arguments (and their usage) are described [here.](https://github.com/ParticularLabs/GitVersion/wiki/Command-Line-Tool)
27+
28+
Also, be aware that if you don't specify the `/b` argument (branch name) then GitVersion will currently fallback to targeting whatever the default branch name happens to be for the repo. This could lead to incorrect results, so for that reason it's recommended to always explicitly specify the branch name.
29+
30+
NB: In Team City, the VCS branch is available from a configuration parameter with the following name:
31+
32+
`teamcity.build.vcs.branch.<VCS root ID>`
33+
34+
Where `<VCS root ID>` is the `VCS root ID` as described on the Configuring `VCS Roots` page.
35+
36+
## Where is the repository stored
37+
GitVersion will checkout the dynamic repository into the %tmp% directory and just keep that dynamic repository up to date, this saves recloning the repository every build.

Docs/buildServerSetup/teamCity.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# TeamCity Setup
2+
## Basic Usage
3+
In [TeamCity](https://www.jetbrains.com/teamcity/) you can create a build step as follows:
4+
5+
* **Runner type:** Command Line
6+
* **Run:** Executable with parameters
7+
* **Command executable:** `GitVersion.exe`
8+
* **Command parameters:** `/output buildserver /updateassemblyinfo true`
9+
10+
Then in your build parameters simply [add a placeholder](https://github.com/Particular/GitVersion/wiki/Variables#recommended-teamcity-setup) of the GitVersion variables you would like to use.
11+
12+
GitVersion writes system parameters into TeamCity, so they will automatically be passed to your build scripts to use.
13+
14+
## Running inside TeamCity
15+
* Make sure to use **agent checkouts** (required, server checkouts do not copy the needed `.git` directory)
16+
- If you want to use *checkout on server*, see [dynamic repositories](dynamicRepositories.md)
17+
* For the moment you need to promote the `%teamcity.build.vcs.branch.{configurationid}%` build parameter to an environment variable with the same name for pull requests to be handled correctly
18+
* We update the TC build number to the GitVersion number automatically
19+
* We output the individual values of the GitVersion version as the build parameter: `GitVersion.*` (Eg: `GitVersion.Major`) if you need access to them in your build script
20+
21+
### NuGet in TeamCity
22+
* Add dummy [parameter](http://confluence.jetbrains.com/display/TCD8/Configuring+Build+Parameters) to
23+
the project called `GitVersion.NuGetVersion`. If many of your projects uses git-flow and SemVer you
24+
can add the parameter to the "root-project" (TeamCity 8.x+)
25+
* Then setup you nuget pack build set the "version" to `%GitVersion.NuGetVersion%`
26+
27+
### When TeamCity -> GitHub can't use https
28+
GitVersion requires the presence of master branch in order to determine the version number. If TeamCity uses https to clone git repos then GitVersion will pull down master branch for you during the build.
29+
30+
If however your TeamCity uses SSH to clone git repos and https is unavailable then GitVersion will error with a message like
31+
32+
> [GitVersionTask.UpdateAssemblyInfo] Error occurred: GitVersion.MissingBranchException: Could not fetch from 'git@github.dev.xero.com:Xero/Bus.git' since LibGit2 does not support the transport. You have most likely cloned using SSH. If there is a remote branch named 'master' then fetch it manually, otherwise please create a local branch named 'master'. ---> LibGit2Sharp.LibGit2SharpException: An error was raised by libgit2. Category = Net (Error).
33+
This transport isn't implemented. Sorry
34+
35+
You need to create a TeamCity build step before your compile step which manually creates a local master branch which tracks remote master. Like so (in powershell):
36+
37+
```Powershell
38+
$branchBeingBuilt = . git symbolic-ref --short -q HEAD
39+
. git pull 2>&1 | write-host
40+
foreach ($remoteBranch in . git branch -r) {
41+
. git checkout $remoteBranch.Trim().Replace("origin/", "") 2>&1 | write-host
42+
. git pull 2>&1 | write-host
43+
}
44+
. git checkout $branchBeingBuilt 2>&1 | write-host
45+
exit 0
46+
```
47+
48+
you should get build output like
49+
50+
```
51+
[Step 1/1]: Ensure all branches are available for GitVersion (Powershell) (5s)
52+
[Step 1/1] From file:///C:/BuildAgent2/system/git/git-12345678
53+
[Step 1/1] * [new branch] master -> origin/master
54+
[Step 1/1] Switched to a new branch 'master'
55+
[Step 1/1] Branch master set up to track remote branch master from origin.
56+
[Step 1/1] Switched to branch 'develop'
57+
```
58+
59+
## Guides
60+
- [Continuous Delivery Setup in TeamCity](http://jake.ginnivan.net/blog/2014/07/09/my-typical-teamcity-build-setup)

Docs/buildServers.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Build Server Support
2+
GitVersion has support for quite a few build servers out of the box. Currently we support:
3+
4+
- TeamCity
5+
- AppVeyor
6+
- Continua Ci
7+
- MyGet
8+
9+
When GitVersion.exe is run with the `/output buildserver` flag instead of outputting Json it will export variables to the current build server.
10+
For instance if you are running in TeamCity after you run `GitVersion /output buildserver` you will have the `%system.GitVersion.SemVer%` available for you to use
11+
12+
When running in MSBuild either from the MSBuild Task or by using the `/proj myproject.sln` GitVersion will make the MSBuild variables available in the format `$(GitVersion_SemVer)`.
13+
14+
## Setup guides
15+
- [AppVeyor](buildServerSetup/appVeyor.md)
16+
- [TeamCity](buildServerSetup/teamCity.md)
17+
18+
## Other plugins/helpers
19+
### GitVersion meta runner for TeamCity
20+
TeamCity has support for meta-runners which allow custom tasks. There is a GitVersion meta-runner available which makes it easy to use GitVersion.
21+
22+
- [Project Link](https://github.com/JetBrains/meta-runner-power-pack/tree/master/gitversion)
23+
24+
### GitVersion for Bamboo
25+
If you use Bamboo then you can install *GitVersion for Bamboo* which gives you a GitVersion task in Bamboo.
26+
27+
- [Blog Post](http://carolynvanslyck.com/blog/2015/03/gitversion-for-bamboo)
28+
- [Project link](http://carolynvanslyck.com/projects/gitversion)
29+
- [Download](https://marketplace.atlassian.com/plugins/com.carolynvs.gitversion)
30+
- [Source](http://carolynvanslyck.com/projects/gitversion)
31+
- [Issues](http://jira.carolynvanslyck.com/browse/GITVER)

0 commit comments

Comments
 (0)