Skip to content

Resolve incorrect generation of meta count when there are multiple remote branches #442

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

Merged
merged 3 commits into from
May 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 6 additions & 0 deletions GitVersionCore.Tests/Fixtures/RemoteRepositoryFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ public class RemoteRepositoryFixture : RepositoryFixtureBase
public string LocalRepositoryPath;
public IRepository LocalRepository;

public RemoteRepositoryFixture(Func<string, IRepository> builder, Config configuration)
: base(builder, configuration)
{
CloneRepository();
}

public RemoteRepositoryFixture(Config configuration)
: base(CreateNewRepository, configuration)
{
Expand Down
27 changes: 27 additions & 0 deletions GitVersionCore.Tests/IntegrationTests/RemoteRepositoryScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@ public void GivenARemoteGitRepositoryWithCommits_ThenClonedLocalShouldMatchRemot
}
}

[Test]
public void GivenARemoteGitRepositoryWithCommitsAndBranches_ThenClonedLocalShouldMatchRemoteVersion()
{
using (var fixture = new RemoteRepositoryFixture(
path =>
{
Repository.Init(path);
Console.WriteLine("Created git repository at '{0}'", path);

var repo = new Repository(path);
repo.MakeCommits(5);

repo.CreateBranch("develop");
repo.CreateBranch("release-1.0");

repo.Checkout("release-1.0");
repo.MakeCommits(5);

return repo;
},
new Config()))
{
fixture.AssertFullSemver("1.0.0-beta.1+5");
fixture.AssertFullSemver("1.0.0-beta.1+5", fixture.LocalRepository);
}
}

[Test]
public void GivenARemoteGitRepositoryAheadOfLocalRepository_ThenChangesShouldPull()
{
Expand Down
2 changes: 1 addition & 1 deletion GitVersionCore/LibGitExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static IEnumerable<Branch> GetBranchesContainingCommit(this Commit commit
yield break;
}

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

Expand Down