Skip to content

Cachehash #968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
11d48a7
Bump develop when release branch is created
JakeGinnivan Jan 17, 2016
dbe0af5
Switched develop default tag to alpha
JakeGinnivan Jan 26, 2016
5bf5c71
Fixed some broken tests
JakeGinnivan Jan 27, 2016
f989a92
Fix some r# errors
JakeGinnivan Apr 17, 2016
5c8195e
Make develop track tags on master
JakeGinnivan Jul 10, 2016
daf0145
All tags on master affect develops version. This addresses #796
JakeGinnivan Jul 10, 2016
4c2d360
Added test from #815 to verify #814 is fixed. (Release branch commit …
JakeGinnivan Jul 10, 2016
d193ec4
This change needs feedback, marking master as beta once this is merge…
JakeGinnivan Jul 10, 2016
3f6bc9e
Updated branching info in docs
JakeGinnivan Jul 17, 2016
e1f3576
Merge pull request #832 from JakeGinnivan/BumpDevelopWhenReleaseBranc…
JakeGinnivan Jul 19, 2016
d9d3f0a
Initial prototype of mainline development working
JakeGinnivan Jul 11, 2016
960def5
Made mainline work for feature branches too
JakeGinnivan Jul 16, 2016
e91288d
Include merge commit in increment calculation for mainline
JakeGinnivan Jul 19, 2016
9d591df
Enable direct commits on master to be treated as a release
JakeGinnivan Jul 19, 2016
9a2cf14
Enable direct commits on master which do not increment SemVer
JakeGinnivan Jul 19, 2016
defc31b
Some initial docs on mainline mode and modes in general
JakeGinnivan Jul 19, 2016
88143f6
Fix build server doc links
Jul 19, 2016
2f591de
Update documentation to use alpha prefix
Jul 19, 2016
786c21e
Merge pull request #957 from pascalberger/FixBuildServerDocLinks
gep13 Jul 19, 2016
96ee0de
Revert "Fix build server doc links"
pascalberger Jul 19, 2016
77e6c64
Merge pull request #959 from GitTools/revert-957-FixBuildServerDocLinks
gep13 Jul 19, 2016
93f2646
Merge pull request #958 from pascalberger/DocFixes
JakeGinnivan Jul 19, 2016
26f5406
Fixed missing info from major release diagram
JakeGinnivan Jul 19, 2016
b2a0d73
Fixed tests
JakeGinnivan Jul 19, 2016
03e5f91
Fixed highlighted doco error
JakeGinnivan Jul 19, 2016
22e0342
Merge pull request #950 from JakeGinnivan/MainlineDevelopmentMode
JakeGinnivan Jul 20, 2016
2ba24a6
Add GitLab documentation to index
Jul 20, 2016
08ace6f
Merge pull request #965 from pascalberger/GitLabDocFix
gep13 Jul 20, 2016
9afd8e9
add a test to ensure cache key is same even if normalized again; modi…
tofutim Jul 22, 2016
e6d77be
read all the files in .git/refs
tofutim Jul 22, 2016
fa64cef
suggestions from DanielRose + make sure to close file after reading u…
tofutim Jul 22, 2016
7958ba8
simplifications and code cleanup from pascal
tofutim Jul 23, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
assembly-versioning-scheme: MajorMinorPatch
next-version: 3.4.0
branches:
master:
tag: beta
ignore:
sha: []
8 changes: 7 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The global configuration options are:

- **`assembly-informational-format:`** Set this to any of the available [variables](/more-info/variables) to change the value of the `AssemblyInformationalVersion` attribute. Default set to `{InformationalVersion}`. It also supports string interpolation (`{MajorMinorPatch}+{Branch}`)

- **`mode:`** Sets the mode of how GitVersion should create a new version. Can be set to either `ContinuousDelivery` or `ContinuousDeployment`. Read more about [ContinuousDelivery](/reference/continuous-delivery/) or [ContinuousDeployment](/reference/continuous-deployment/).
- **`mode:`** Sets the mode of how GitVersion should create a new version. Read more at [versioning mode](./versioning-mode.md)

- **`continuous-delivery-fallback-tag:`** When using `mode: ContinuousDeployment`, the value specified will be used as the pre-release tag for branches which do not have one specified. Default set to `ci`.

Expand All @@ -36,6 +36,8 @@ The global configuration options are:

- **`patch-version-bump-message:`** The regex to match commit messages with to perform a patch version increment. Default set to `'\+semver:\s?(fix|patch)'`, which will match occurrences of `+semver: fix` and `+semver: patch` in a commit message.

- **`no-bump-message:`** Used to tell GitVersion not to increment when in Mainline development mode. Default `\+semver:\s?(none|skip)`, which will match occurrences of `+semver: none` and `+semver: skip`

- **`legacy-semver-padding:`** The number of characters to pad `LegacySemVer` to in the `LegacySemVerPadded` [variable](/more-info/variables). Is default set to `4`, which will pad the `LegacySemVer` value of `3.0.0-beta1` to `3.0.0-beta0001`.

- **`build-metadata-padding:`** The number of characters to pad `BuildMetaData` to in the `BuildMetaDataPadded` [variable](/more-info/variables). Is default set to `4`, which will pad the `BuildMetaData` value of `1` to `0001`.
Expand All @@ -48,6 +50,10 @@ The global configuration options are:
- **`sha:`** A sequence of SHAs to be excluded from the version calculations. Useful when there is a rogue commit in history yielding a bad version.
- **`commits-before:`** Allows to setup an exclusion range. Effectively any commit < `commits-before` will be ignored.

- **`is-develop:`** Indicates this branch config represents develop in GitFlow

**`is-release-branch:`** Indicates this branch config represents a release branch in GitFlow

## Branch configuration

Then we have branch specific configuration, which looks something like this:
Expand Down
2 changes: 1 addition & 1 deletion docs/git-branching-strategies/gitflow-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature branches will take the feature branch name and use that as the pre-relea

![GitFlow](img/05119d0cd4ecaaefff94_feature-branch.png)

Notice after the feature branch is merged, the version on `develop` is `1.3.0-unstable.3`. This is due to `develop` running in *continuous deployment* mode. If you configured `develop` to use *continuous delivery* the version would still be `1.3.0-unstable.1` and you would have to use release tags to increment the `unstable.1`.
Notice after the feature branch is merged, the version on `develop` is `1.3.0-alpha.3`. This is due to `develop` running in *continuous deployment* mode. If you configured `develop` to use *continuous delivery* the version would still be `1.3.0-alpha.1` and you would have to use release tags to increment the `alpha.1`.

You can see the different on the feature branch itself, notice the version is the same before and after the commit on the feature branch? Only the metadata has changed. If you released the feature branch artifacts then tagged the commit, the following commit would increase to `-beta.2`.

Expand Down
10 changes: 5 additions & 5 deletions docs/git-branching-strategies/gitflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ Long version:
* major: `masterMergeVersion.Major`
* minor: `masterMergeVersion.Minor + 1` (0 if the override above is used)
* patch: 0
* pre-release: `unstable{n}` where n = how many commits `develop` is in front of `masterVersionCommit.Date` ('0' padded to 4 characters)
* pre-release: `alpha.{n}` where n = how many commits `develop` is in front of `masterVersionCommit.Date` ('0' padded to 4 characters)

Long version:

{major}.{minor}.{patch}-{pre-release} Branch:'{branchName}' Sha:'{sha}'
1.2.3-unstable645 Branch:'develop' Sha:'a682956dccae752aa24597a0f5cd939f93614509'
1.2.3-alpha.645 Branch:'develop' Sha:'a682956dccae752aa24597a0f5cd939f93614509'

### Hotfix branches

Expand Down Expand Up @@ -108,13 +108,13 @@ TODO: feature branches cannot start with a SemVer. to stop people from create br
* major: `masterMergeVersion.Major`
* minor: `masterMergeVersion.Minor + 1` (0 if the override above is used)
* patch: 0
* pre-release: `unstable.feature-{n}` where n = First 8 characters of the commit SHA of the first commit
* pre-release: `alpha.feature-{n}` where n = First 8 characters of the commit SHA of the first commit


Long version:

{major}.{minor}.{patch}-{pre-release} Branch:'{branchName}' Sha:'{sha}'
1.2.3-unstable.feature-a682956d Branch:'feature1' Sha:'a682956dccae752aa24597a0f5cd939f93614509'
1.2.3-alpha.feature-a682956d Branch:'feature1' Sha:'a682956dccae752aa24597a0f5cd939f93614509'

### Pull-request branches

Expand All @@ -125,7 +125,7 @@ Branch naming convention: anything except `master`, `develop`, `release-{n}`, or
* major: `masterMergeVersion.Major`
* minor: `masterMergeVersion.Minor + 1` (0 if the override above is used)
* patch: 0
* pre-release: `unstable.pull{n}` where n = the pull request number ('0' padded to 4 characters)
* pre-release: `alpha.pull{n}` where n = the pull request number ('0' padded to 4 characters)

## Nightly Builds

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/mainline-mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/more-info/version-increments.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ This causes problems for people as NuGet and other package managers do not suppo
There are a few ways to handle this problem depending on what your requirements are:

### 1. GitFlow
If you are using GitFlow then builds off the `develop` branch will actually *increment on every commit*. This is known in GitVersion as *continuous deployment mode*. By default `develop` builds are tagged with the `unstable` pre-release tag. This is so they are sorted higher than release branches.
If you are using GitFlow then builds off the `develop` branch will actually *increment on every commit*. This is known in GitVersion as *continuous deployment mode*. By default `develop` builds are tagged with the `alpha` pre-release tag. This is so they are sorted higher than release branches.

If you need to consume packages built from develop, we recommend publishing these packages to a separate NuGet feed as an alpha channel. That way you can publish beta/release candidate builds and only people who opt into the alpha feed will see the unstable packages.
If you need to consume packages built from develop, we recommend publishing these packages to a separate NuGet feed as an alpha channel. That way you can publish beta/release candidate builds and only people who opt into the alpha feed will see the alpha packages.

### 2. Octopus deploy
See [Octopus deploy](../build-server-support/build-server/octopus-deploy.md)
Expand Down
42 changes: 42 additions & 0 deletions docs/versioning-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Versioning modes
GitVersion has multiple modes to fit different different ways of working.


## Continuous Delivery
This is the default mode, GitVersion calculates the next version and will use that until that is released. For instance:

- 1.1.0+5
- 1.1.0+6
- 1.1.0+7 <-- This is the artifact we release, tag the commit which created this version
- 1.1.1+0

Tags are required in this mode to communicate when the release is done as it's an external manual process.

## Continuous deployment
Sometimes you just want the version to keep changing and continuously deploy. A good case for this is when using Octopus deploy, as you cannot publish the same version of a package into the same feed.

For this mode we followed the logic in this blog post by Xavier Decoster on the issues of incrementing automatically - http://www.xavierdecoster.com/semantic-versioning-auto-incremented-nuget-package-versions

As such we force a pre-release tag on all branches, this is fine for applications but can cause problems for libraries. As such this mode may or may not work for you, which leads us into a new mode in v4. Mainline development.

## Mainline development
Mainline development works more like the Continuous Delivery mode, except that it tells GitVersion to *infer* releases from merges and commits to `master`.

This mode is great if you do not want to tag each release because you simply deploy every commit to master. The behaviour of this mode is as follows:

1. Calclate a base version (likely a tag in this mode)
1. Walk all commits from the base version commit
1. When a merge commit is found:
- Calculate increments for each direct commit on master
- Calculate the increment for the branch
1. Calculate increments for each remaining direct commit
1. For feature branches then calculate increment for the commits so far on your feature branch.

If you *do not want* GitVersion to treat a commit or a pull request as a release and increment the version you can use `+semver: none` or `+semver: skip` in a commit message to skip incrementing for that commit.

Here is an example of what mainline development looks like:

![Mainline mode](./img/mainline-mode.png)


**WARNING:** This approach can slow down over time, we recommend to tag intermitently (maybe for minor or major releases) because then GitVersion will start the version calculation from that point. Much like a snapshot in an event sourced system. We will probably add in warnings to tag when things are slowing down.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pages:
- Build Servers:
- AppVeyor: build-server-support/build-server/appveyor.md
- Bamboo: build-server-support/build-server/bamboo.md
- GitLab CI: build-server-support/build-server/gitlab.md
- Continua CI: build-server-support/build-server/continua.md
- Jenkins: build-server-support/build-server/jenkins.md
- MyGet: build-server-support/build-server/myget.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ continuous-delivery-fallback-tag: ci
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
Expand All @@ -16,42 +17,56 @@ branches:
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: false
is-release-branch: false
releases?[/-]:
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: false
is-release-branch: true
features?[/-]:
mode: ContinuousDelivery
tag: useBranchName
increment: Inherit
prevent-increment-of-merged-branch-version: false
track-merge-target: false
is-develop: false
is-release-branch: false
(pull|pull\-requests|pr)[/-]:
mode: ContinuousDelivery
tag: PullRequest
increment: Inherit
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
is-develop: false
is-release-branch: false
hotfix(es)?[/-]:
mode: ContinuousDelivery
tag: beta
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: false
is-develop: false
is-release-branch: false
support[/-]:
mode: ContinuousDelivery
tag: ''
increment: Patch
prevent-increment-of-merged-branch-version: true
track-merge-target: false
is-develop: false
is-release-branch: false
dev(elop)?(ment)?$:
mode: ContinuousDeployment
tag: unstable
tag: alpha
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
is-develop: true
is-release-branch: false
ignore:
sha: []
18 changes: 9 additions & 9 deletions src/GitVersionCore.Tests/ConfigProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void CanReadDefaultDocument()
var config = ConfigurationProvider.Provide(repoPath, fileSystem);
config.AssemblyVersioningScheme.ShouldBe(AssemblyVersioningScheme.MajorMinorPatch);
config.AssemblyInformationalFormat.ShouldBe(null);
config.Branches["dev(elop)?(ment)?$"].Tag.ShouldBe("unstable");
config.Branches["dev(elop)?(ment)?$"].Tag.ShouldBe("alpha");
config.Branches["releases?[/-]"].Tag.ShouldBe("beta");
config.TagPrefix.ShouldBe(ConfigurationProvider.DefaultTagPrefix);
config.NextVersion.ShouldBe(null);
Expand All @@ -242,10 +242,10 @@ public void WarnOnExistingGitVersionConfigYamlFile(string path)

var logOutput = string.Empty;
Action<string> action = info => { logOutput = info; };
Logger.SetLoggers(action, action, action);

ConfigurationProvider.Verify(workingPath, repoPath, fileSystem);

using (Logger.AddLoggersTemporarily(action, action, action))
{
ConfigurationProvider.Verify(workingPath, repoPath, fileSystem);
}
var configFileDeprecatedWarning = string.Format("{0}' is deprecated, use '{1}' instead", ConfigurationProvider.ObsoleteConfigFileName, ConfigurationProvider.DefaultConfigFileName);
logOutput.Contains(configFileDeprecatedWarning).ShouldBe(true);
}
Expand Down Expand Up @@ -289,10 +289,10 @@ public void NoWarnOnGitVersionYmlFile()

var s = string.Empty;
Action<string> action = info => { s = info; };
Logger.SetLoggers(action, action, action);

ConfigurationProvider.Provide(repoPath, fileSystem);

using (Logger.AddLoggersTemporarily(action, action, action))
{
ConfigurationProvider.Provide(repoPath, fileSystem);
}
s.Length.ShouldBe(0);
}

Expand Down
24 changes: 21 additions & 3 deletions src/GitVersionCore.Tests/ExecuteCoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ public void SetUp()
fileSystem = new FileSystem();
}

[Test]
public void CacheKeySameAfterReNormalizing()
{
var versionAndBranchFinder = new ExecuteCore(fileSystem);

RepositoryScope(versionAndBranchFinder, (fixture, vv) =>
{
var targetUrl = "https://github.com/GitTools/GitVersion.git";
var targetBranch = "refs/head/master";
var gitPreparer = new GitPreparer(targetUrl, null, new Authentication(), false, fixture.RepositoryPath);
//var cacheKey0 = GitVersionCacheKeyFactory.Create(fileSystem, gitPreparer, null);
gitPreparer.Initialise(true, targetBranch);
var cacheKey1 = GitVersionCacheKeyFactory.Create(fileSystem, gitPreparer, null);
gitPreparer.Initialise(true, targetBranch);
var cacheKey2 = GitVersionCacheKeyFactory.Create(fileSystem, gitPreparer, null);

cacheKey2.Value.ShouldBe(cacheKey1.Value);
});
}

[Test]
public void CacheFileExistsOnDisk()
{
Expand Down Expand Up @@ -200,12 +220,10 @@ string RepositoryScope(ExecuteCore executeCore = null, Action<EmptyRepositoryFix
Action<string> infoLogger = s =>
{
infoBuilder.AppendLine(s);
Console.WriteLine(s);
};
executeCore = executeCore ?? new ExecuteCore(fileSystem);

Logger.SetLoggers(infoLogger, Console.WriteLine, Console.WriteLine);

using (Logger.AddLoggersTemporarily(infoLogger, s => {}, s => { }))
using (var fixture = new EmptyRepositoryFixture())
{
fixture.Repository.MakeACommit();
Expand Down
12 changes: 8 additions & 4 deletions src/GitVersionCore.Tests/GitToolsTestingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ public static Config ApplyDefaults(this Config config)
return config;
}

public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true)
public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Config configuration = null, IRepository repository = null, string commitId = null, bool isForTrackedBranchOnly = true)
{
ConfigurationProvider.ApplyDefaultsTo(configuration);
if (configuration == null)
{
configuration = new Config();
ConfigurationProvider.ApplyDefaultsTo(configuration);
}
var gitVersionContext = new GitVersionContext(repository ?? fixture.Repository, configuration, isForTrackedBranchOnly, commitId);
var executeGitVersion = ExecuteGitVersion(gitVersionContext);
var variables = VariableProvider.GetVariablesFor(executeGitVersion, gitVersionContext.Configuration, gitVersionContext.IsCurrentCommitTagged);
Expand Down Expand Up @@ -55,7 +59,7 @@ public static void AssertFullSemver(this RepositoryFixtureBase fixture, Config c
}
if (commitId == null)
{
fixture.SequenceDiagram.NoteOver(fullSemver, fixture.Repository.Head.FriendlyName, color: "#D3D3D3");
fixture.SequenceDiagram.NoteOver(fullSemver, fixture.Repository.Head.FriendlyName, color: "#D3D3D3");
}
}

Expand All @@ -70,7 +74,7 @@ static SemanticVersion ExecuteGitVersion(GitVersionContext context)
/// </summary>
public static void InitialiseRepo(this RemoteRepositoryFixture fixture)
{
// TODO !!new GitPreparer(null, null, new Authentication(), false, fixture.LocalRepositoryFixture.RepositoryPath).Initialise(true, null);
new GitPreparer(null, null, new Authentication(), false, fixture.LocalRepositoryFixture.RepositoryPath).Initialise(true, null);
}
}
}
1 change: 1 addition & 0 deletions src/GitVersionCore.Tests/GitVersionCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<Compile Include="ConfigProviderTests.cs" />
<Compile Include="GitVersionContextTests.cs" />
<Compile Include="Helpers\DirectoryHelper.cs" />
<Compile Include="IntegrationTests\MainlineDevelopmentMode.cs" />
<Compile Include="Mocks\MockThreadSleep.cs" />
<Compile Include="OperationWithExponentialBackoffTests.cs" />
<Compile Include="Init\InitScenarios.cs" />
Expand Down
Loading