Skip to content

Commit 9fdcb69

Browse files
committed
Fixed test
1 parent 730dbfb commit 9fdcb69

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ public void WhenMergingReleaseBackToDevShouldNotResetBetaVersion()
238238

239239
//but keep working on the release
240240
fixture.Repository.Checkout("release-2.0.0");
241-
242-
fixture.AssertFullSemver("2.0.0-beta.2+3");
241+
fixture.AssertFullSemver("2.0.0-beta.2+2");
243242
}
244243
}
245244
}

GitVersionCore/BranchConfigurationCalculator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEv
7373
}
7474
excludedBranches.ToList().ForEach(excludedInheritBranches.Add);
7575

76-
var branchPoint = currentBranch.FindCommitBranchWasBranchedFrom(repository, onlyEvaluateTrackedBranches, excludedInheritBranches.ToArray());
76+
var branchPoint = currentBranch.FindCommitBranchWasBranchedFrom(repository, excludedInheritBranches.ToArray());
7777

7878
List<Branch> possibleParents;
79-
if (branchPoint.Sha == currentCommit.Sha)
79+
if (branchPoint == null)
8080
{
8181
possibleParents = currentCommit.GetBranchesContainingCommit(repository, true).Except(excludedInheritBranches).ToList();
8282
}

GitVersionCore/LibGitExtensions.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ public static Branch FindBranch(this IRepository repository, string branchName)
2424
return repository.Branches.FirstOrDefault(x => x.Name == "origin/" + branchName);
2525
}
2626

27-
public static Commit FindCommitBranchWasBranchedFrom(this Branch branch, IRepository repository, bool onlyTrackedBranches, params Branch[] excludedBranches)
27+
public static Commit FindCommitBranchWasBranchedFrom(this Branch branch, IRepository repository, params Branch[] excludedBranches)
2828
{
2929
var otherBranches = repository.Branches.Where(b => !b.IsRemote).Except(excludedBranches).Except(new [] { branch });
3030
var mergeBases = otherBranches.Select(b =>
3131
{
32-
var mergeBase = repository.Commits.FindMergeBase(b.Tip, branch.Tip);
32+
var otherCommit = b.Tip;
33+
if (b.Tip.Parents.Contains(branch.Tip))
34+
{
35+
otherCommit = b.Tip.Parents.First();
36+
}
37+
var mergeBase = repository.Commits.FindMergeBase(otherCommit, branch.Tip);
3338
return mergeBase;
3439
}).Where(b => b != null);
3540
return mergeBases.OrderByDescending(b => b.Committer.When).FirstOrDefault();

GitVersionCore/VersionCalculation/BaseVersionCalculators/VersionInBranchBaseVersionStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public override BaseVersion GetVersion(GitVersionContext context)
99
var versionInBranch = GetVersionInBranch(context);
1010
if (versionInBranch != null)
1111
{
12-
var commitBranchWasBranchedFrom = context.CurrentBranch.FindCommitBranchWasBranchedFrom(context.Repository, context.OnlyEvaluateTrackedBranches);
12+
var commitBranchWasBranchedFrom = context.CurrentBranch.FindCommitBranchWasBranchedFrom(context.Repository);
1313
var branchNameOverride = context.CurrentBranch.Name.RegexReplace("[-/]" + versionInBranch.Item1, string.Empty);
1414
return new BaseVersion("Version in branch name", false, versionInBranch.Item2, commitBranchWasBranchedFrom, branchNameOverride);
1515
}

0 commit comments

Comments
 (0)