Skip to content

Commit d796782

Browse files
committed
Merge remote-tracking branch 'upstream/master' into release/3.0.0
2 parents 2394a10 + 76b0bc2 commit d796782

17 files changed

+76
-25
lines changed

Docs/configurationOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Confiuration options
1+
# Configuration options

Docs/index.md renamed to Docs/readme.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ GitVersion is a tool to help you achieve Semantic Versioning on your project.
44
This influences many of the decisions GitVersion has made, please read and understand this page as it will help you start using GitVersion effectively!
55

66
## Assumptions/Rules
7-
### You tag releases when you release, not before
8-
GitVersion assumes that tags are used to *tag a release* and not used to build a release.
9-
10-
This means that the version is calculated pre-emptively, if you currently tag, build then release that tag then GitVersion will probably not work for you.
11-
127
### Tags override other rules
138
If a commit is tagged, then GitVersion will *always* use that version over any calculated versions. This is so if you rebuild a tag then the same version will be produced.
149

@@ -39,6 +34,6 @@ We recognise that a single formatted version number does not work for all cases.
3934
You can just run `GitVersion.exe` in your repository to see what variables are available (by default a json object is returned).
4035

4136
## Exe or MSBuild Task
42-
There are two ways to consume GitVersion, the first is by running GitVersion.exe. The second is an MSBUild task. The MSBuild task is really easy to get up and running, simply install GitVersionTask from NuGet and it will integrate into your project and write out variables to your build server if it's running on one. The exe offers more options and works for not just .net projects.
37+
There are two ways to consume GitVersion, the first is by running GitVersion.exe. The second is an MSBuild task. The MSBuild task is really easy to get up and running, simply install GitVersionTask from NuGet and it will integrate into your project and write out variables to your build server if it's running on one. The exe offers more options and works for not just .net projects.
4338

4439
Read more about [using GitVersion](./usage.md)

Docs/versionSources.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ GitVersion will find all tags on the current branch and return the highest one.
1717
Will increment: true
1818

1919
### Version in branch name
20-
If the branch has a version in it, then that version will be returned
20+
If the branch has a version in it, then that version will be returned.
2121

2222
Will increment: false
2323

@@ -27,7 +27,7 @@ If a branch with a version number in it is merged into the current branch, that
2727
Will increment: false
2828

2929
### GitVersionConfig.yaml
30-
If the next-version property is specified in the config file, it will be used as a version source.
30+
If the `next-version` property is specified in the config file, it will be used as a version source.
3131

3232
Will increment: false
3333

GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void ReleaseBranchWithNextVersionSetInConfig()
8686
}
8787

8888
[Test]
89-
public void CanTakeVersionFromReleaseBranchWithTagOverriden()
89+
public void CanTakeVersionFromReleaseBranchWithTagOverridden()
9090
{
9191
var config = new Config();
9292
config.Branches["release[/-]"].Tag = "rc";

GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void GivenARemoteGitRepositoryAheadOfLocalRepository_ThenChangesShouldPul
5757
}
5858

5959
[Test]
60-
public void GivenARemoteGitRepositoryWhenCheckingOutDetachedhead_UsingExistingImplemenationThrowsException()
60+
public void GivenARemoteGitRepositoryWhenCheckingOutDetachedhead_UsingExistingImplementationThrowsException()
6161
{
6262

6363
using (var fixture = new RemoteRepositoryFixture(new Config()))

GitVersionCore.Tests/VersionCalculation/Strategies/MergeMessageBaseVersionStrategyTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Another commit message
8181
A commit message")]
8282
[TestCase(@"Merge branch 'release/Sprint_2.0_Holdings_Computed_Balances'")]
8383
[TestCase(@"Merge branch 'feature/fix-for-08.14-push'")]
84-
public void MergeMessagesThatsNotRelatedToGitVersion(string commitMessage)
84+
public void MergeMessagesThatIsNotRelatedToGitVersion(string commitMessage)
8585
{
8686

8787
var parents = GetParents(true);

GitVersionCore/BuildServers/GitHelper.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace GitVersion
22
{
3+
using System;
34
using LibGit2Sharp;
45
using System.Collections.Generic;
56
using System.Linq;
@@ -164,6 +165,20 @@ static void CreateFakeBranchPointingAtThePullRequestTip(Repository repo, Authent
164165
repo.Checkout(fakeBranchName);
165166
}
166167

168+
internal static IEnumerable<DirectReference> GetRemoteTipsUsingUsernamePasswordCredentials(Repository repo, string repoUrl, string username, string password)
169+
{
170+
// This is a work-around as long as https://github.com/libgit2/libgit2sharp/issues/1099 is not fixed
171+
var remote = repo.Network.Remotes.Add(Guid.NewGuid().ToString(), repoUrl);
172+
try
173+
{
174+
return GetRemoteTipsUsingUsernamePasswordCredentials(repo, remote, username, password);
175+
}
176+
finally
177+
{
178+
repo.Network.Remotes.Remove(remote.Name);
179+
}
180+
}
181+
167182
static IEnumerable<DirectReference> GetRemoteTipsUsingUsernamePasswordCredentials(Repository repo, Remote remote, string username, string password)
168183
{
169184
return repo.Network.ListReferences(remote, (url, fromUrl, types) => new UsernamePasswordCredentials
@@ -185,7 +200,9 @@ static void CreateMissingLocalBranchesFromRemoteTrackingOnes(Repository repo, st
185200

186201
foreach (var remoteTrackingReference in repo.Refs.FromGlob(prefix + "*").Where(r => r.CanonicalName != remoteHeadCanonicalName))
187202
{
188-
var localCanonicalName = "refs/heads/" + remoteTrackingReference.CanonicalName.Substring(prefix.Length);
203+
var remoteTrackingReferenceName = remoteTrackingReference.CanonicalName;
204+
var branchName = remoteTrackingReferenceName.Substring(prefix.Length);
205+
var localCanonicalName = "refs/heads/" + branchName;
189206

190207
if (repo.Refs.Any(x => x.CanonicalName == localCanonicalName))
191208
{
@@ -203,6 +220,9 @@ static void CreateMissingLocalBranchesFromRemoteTrackingOnes(Repository repo, st
203220
{
204221
repo.Refs.Add(localCanonicalName, new ObjectId(symbolicReference.ResolveToDirectReference().TargetIdentifier), true);
205222
}
223+
224+
var branch = repo.Branches[branchName];
225+
repo.Branches.Update(branch, b => b.TrackedBranch = remoteTrackingReferenceName);
206226
}
207227
}
208228

GitVersionCore/Configuration/Wizard/EditConfigStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected override string GetPrompt(Config config)
3030
{
3131
return string.Format(@"Which would you like to change?
3232
33-
0) Save changes
33+
0) Save changes and exit
3434
1) Exit without saving
3535
2) Branch specific configuration
3636
3) Branch Increment mode (per commit/after tag) (Current: {0})

GitVersionCore/Configuration/Wizard/PickBranchingStrategy1Step.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected override string GetPrompt(Config config)
2727
{
2828
return @"GitVersion can try to recommend you a branching strategy based on a few questions.
2929
30-
Do you need to maintain mutliple versions of your application simultanously in production? (y/n)";
30+
Do you need to maintain multiple versions of your application simultaneously in production? (y/n)";
3131
}
3232

3333
protected override string DefaultResult

GitVersionCore/Configuration/Wizard/PickBranchingStrategy2Step.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
1313
Console.WriteLine("GitFlow is likely a good fit, the 'develop' branch can be used " +
1414
"for active development while stabilising the next release.");
1515
Console.WriteLine();
16-
Console.WriteLine("GitHubFlow is designed for a lightwieght workflow where master is always " +
16+
Console.WriteLine("GitHubFlow is designed for a lightweight workflow where master is always " +
1717
"good to deploy to production and feature branches are used to stabilise " +
18-
"features, once stable they can be released in the next release");
18+
"features, once stable they are merged to master and made available in the next release");
1919
steps.Enqueue(new PickBranchingStrategyStep());
2020
return StepResult.Ok();
2121
case "n":

GitVersionCore/Configuration/Wizard/PickBranchingStrategy3Step.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
1313
Console.WriteLine("GitFlow could be a better fit than GitHubFlow for you.");
1414
Console.WriteLine();
1515
Console.WriteLine("GitVersion increments the SemVer for each commit on the develop branch by default, " +
16-
"this means all packages build from develop can be published to a single NuGet feed.");
16+
"this means all packages built from develop can be published to a single NuGet feed.");
1717
break;
1818
case "n":
1919
Console.WriteLine("We recommend the GitHubFlow branching strategy, it sounds like you will " +

GitVersionCore/Configuration/Wizard/SetBranchIncrementMode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
3535

3636
protected override string GetPrompt(Config config)
3737
{
38-
return string.Format(@"What do you want the increment mode for {0} to be
38+
return string.Format(@"What do you want the increment mode for {0} to be?
3939
4040
0) Back
4141
1) Follow SemVer and only increment when a release has been tagged (continuous delivery mode)

GitVersionCore/Configuration/Wizard/SetBranchTag.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public class SetBranchTag : ConfigInitWizardStep
99

1010
public SetBranchTag(string name, BranchConfig branchConfig)
1111
{
12-
this.branchConfig = branchConfig;
1312
this.name = name;
13+
this.branchConfig = branchConfig;
1414
}
1515

1616
protected override StepResult HandleResult(string result, Queue<ConfigInitWizardStep> steps, Config config)

GitVersionCore/Configuration/Wizard/SimpleOrTutorialStep.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected override StepResult HandleResult(string result, Queue<ConfigInitWizard
2020

2121
protected override string GetPrompt(Config config)
2222
{
23-
return "Would you like to run an extended init (more like a tutorial) (y/n)";
23+
return "Would you like to run an extended init? (more like a tutorial) (y/n)";
2424
}
2525

2626
protected override string DefaultResult

GitVersionCore/GitPreparer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static string CreateDynamicRepository(string targetPath, Authentication authenti
172172

173173
if (newHead == null)
174174
{
175-
var remoteReference = GetRemoteReference(repository, targetBranch, repositoryUrl);
175+
var remoteReference = GetRemoteReference(repository, targetBranch, repositoryUrl, authentication);
176176
if (remoteReference != null)
177177
{
178178
repository.Network.Fetch(repositoryUrl, new[]
@@ -202,11 +202,11 @@ private static Reference GetLocalReference(Repository repository, string branchN
202202
return repository.Refs.FirstOrDefault(localRef => string.Equals(localRef.CanonicalName, targetBranchName));
203203
}
204204

205-
private static DirectReference GetRemoteReference(Repository repository, string branchName, string repositoryUrl)
205+
private static DirectReference GetRemoteReference(Repository repository, string branchName, string repositoryUrl, Authentication authentication)
206206
{
207207
var targetBranchName = branchName.GetCanonicalBranchName();
208-
var remoteReferences = repository.Network.ListReferences(repositoryUrl);
209208

209+
var remoteReferences = GitHelper.GetRemoteTipsUsingUsernamePasswordCredentials(repository, repositoryUrl, authentication.Username, authentication.Password);
210210
return remoteReferences.FirstOrDefault(remoteRef => string.Equals(remoteRef.CanonicalName, targetBranchName));
211211
}
212212
}

GitVersionCore/LibGitExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static void CheckoutFilesIfExist(this IRepository repository, params stri
121121
return;
122122
}
123123

124-
Logger.WriteInfo(string.Format("Checking out files that might be needed later in dynamic repository"));
124+
Logger.WriteInfo("Checking out files that might be needed later in dynamic repository");
125125

126126
foreach (var fileName in fileNames)
127127
{

GitVersionExe.Tests/GitPreparerTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,5 +208,41 @@ public void UsesGitVersionConfigWhenCreatingDynamicRepository()
208208
}
209209
}
210210

211+
[Test]
212+
public void UsingDynamicRepositoryWithFeatureBranchWorks()
213+
{
214+
var repoName = Guid.NewGuid().ToString();
215+
var tempPath = Path.GetTempPath();
216+
var tempDir = Path.Combine(tempPath, repoName);
217+
Directory.CreateDirectory(tempDir);
218+
219+
try
220+
{
221+
using (var mainRepositoryFixture = new EmptyRepositoryFixture(new Config()))
222+
{
223+
var commitId = mainRepositoryFixture.Repository.MakeACommit().Id.Sha;
224+
225+
var arguments = new Arguments
226+
{
227+
TargetPath = tempDir,
228+
TargetUrl = mainRepositoryFixture.RepositoryPath,
229+
TargetBranch = "feature1",
230+
CommitId = commitId
231+
};
232+
233+
var gitPreparer = new GitPreparer(arguments.TargetUrl, arguments.DynamicRepositoryLocation, arguments.Authentication, arguments.TargetBranch, arguments.NoFetch, arguments.TargetPath);
234+
gitPreparer.Initialise(true);
235+
236+
mainRepositoryFixture.Repository.CreateBranch("feature1").Checkout();
237+
238+
Assert.DoesNotThrow(() => gitPreparer.Initialise(true));
239+
}
240+
}
241+
finally
242+
{
243+
Directory.Delete(tempDir, true);
244+
}
245+
}
246+
211247
// TODO test around normalisation
212248
}

0 commit comments

Comments
 (0)