Skip to content

Commit a634f09

Browse files
committed
Merge pull request #442 from MeirionHughes/master
Resolve incorrect generation of meta count when there are multiple remote branches
2 parents 1a55091 + 276b1a3 commit a634f09

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

GitVersionCore.Tests/Fixtures/RemoteRepositoryFixture.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ public class RemoteRepositoryFixture : RepositoryFixtureBase
88
public string LocalRepositoryPath;
99
public IRepository LocalRepository;
1010

11+
public RemoteRepositoryFixture(Func<string, IRepository> builder, Config configuration)
12+
: base(builder, configuration)
13+
{
14+
CloneRepository();
15+
}
16+
1117
public RemoteRepositoryFixture(Config configuration)
1218
: base(CreateNewRepository, configuration)
1319
{

GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,33 @@ public void GivenARemoteGitRepositoryWithCommits_ThenClonedLocalShouldMatchRemot
1616
}
1717
}
1818

19+
[Test]
20+
public void GivenARemoteGitRepositoryWithCommitsAndBranches_ThenClonedLocalShouldMatchRemoteVersion()
21+
{
22+
using (var fixture = new RemoteRepositoryFixture(
23+
path =>
24+
{
25+
Repository.Init(path);
26+
Console.WriteLine("Created git repository at '{0}'", path);
27+
28+
var repo = new Repository(path);
29+
repo.MakeCommits(5);
30+
31+
repo.CreateBranch("develop");
32+
repo.CreateBranch("release-1.0");
33+
34+
repo.Checkout("release-1.0");
35+
repo.MakeCommits(5);
36+
37+
return repo;
38+
},
39+
new Config()))
40+
{
41+
fixture.AssertFullSemver("1.0.0-beta.1+5");
42+
fixture.AssertFullSemver("1.0.0-beta.1+5", fixture.LocalRepository);
43+
}
44+
}
45+
1946
[Test]
2047
public void GivenARemoteGitRepositoryAheadOfLocalRepository_ThenChangesShouldPull()
2148
{

GitVersionCore/LibGitExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static IEnumerable<Branch> GetBranchesContainingCommit(this Commit commit
5656
yield break;
5757
}
5858

59-
foreach (var branch in repository.Branches)
59+
foreach (var branch in repository.Branches.Where(b => (onlyTrackedBranches && !b.IsTracking)))
6060
{
6161
var commits = repository.Commits.QueryBy(new CommitFilter { Since = branch }).Where(c => c.Sha == commit.Sha);
6262

0 commit comments

Comments
 (0)