Skip to content

Commit 0efe0b4

Browse files
committed
Merge pull request #724 from gep13/RemoveRedundantCode
Remove requirement on master branch existing
2 parents 121a55f + 81c086c commit 0efe0b4

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/GitVersionCore.Tests/IntegrationTests/OtherScenarios.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ public void DoNotBlowUpWhenMasterAndDevelopPointAtSameCommit()
3030
}
3131
}
3232

33+
[Test]
34+
public void AllowNotHavingMaster()
35+
{
36+
using (var fixture = new EmptyRepositoryFixture(new Config()))
37+
{
38+
fixture.Repository.MakeACommit();
39+
fixture.Repository.MakeATaggedCommit("1.0.0");
40+
fixture.Repository.MakeACommit();
41+
fixture.Repository.Checkout(fixture.Repository.CreateBranch("develop"));
42+
fixture.Repository.Branches.Remove(fixture.Repository.Branches["master"]);
43+
44+
fixture.AssertFullSemver("1.1.0-unstable.1");
45+
}
46+
}
47+
3348
[Test]
3449
public void DoNotBlowUpWhenDevelopAndFeatureBranchPointAtSameCommit()
3550
{

src/GitVersionCore/GitVersionFinder.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public SemanticVersion FindVersion(GitVersionContext context)
2323

2424
void EnsureMainTopologyConstraints(GitVersionContext context)
2525
{
26-
EnsureLocalBranchExists(context.Repository, "master");
2726
EnsureHeadIsNotDetached(context);
2827
}
2928

@@ -40,16 +39,5 @@ void EnsureHeadIsNotDetached(GitVersionContext context)
4039
context.CurrentCommit.Id.ToString(7));
4140
throw new WarningException(message);
4241
}
43-
44-
void EnsureLocalBranchExists(IRepository repository, string branchName)
45-
{
46-
if (repository.FindBranch(branchName) != null)
47-
{
48-
return;
49-
}
50-
51-
var existingBranches = string.Format("'{0}'", string.Join("', '", repository.Branches.Select(x => x.CanonicalName)));
52-
throw new WarningException(string.Format("This repository doesn't contain a branch named '{0}'. Please create one. Existing branches: {1}", branchName, existingBranches));
53-
}
5442
}
5543
}

0 commit comments

Comments
 (0)