-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switched to configuration option rather than hardcoding branch name
- Loading branch information
1 parent
1ee64bf
commit 1d1b0c4
Showing
9 changed files
with
51 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 23 additions & 4 deletions
27
...Core/VersionCalculation/BaseVersionCalculators/GitFlowDevelopBranchBaseVersionStrategy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,39 @@ | ||
namespace GitVersion.VersionCalculation.BaseVersionCalculators | ||
{ | ||
using System; | ||
using System.Linq; | ||
using LibGit2Sharp; | ||
|
||
public class GitFlowDevelopBranchBaseVersionStrategy : HighestTagBaseVersionStrategy | ||
{ | ||
protected override bool IsValidTag(string branchName, Tag tag, Commit commit) | ||
protected override bool IsValidTag(GitVersionContext context, string branchName, Tag tag, Commit commit) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(branchName)) | ||
{ | ||
if (branchName.ToLower().EndsWith("/develop")) | ||
if (context.Configuration.TrackMergeTarget) | ||
{ | ||
return tag.IsDirectMergeFromCommit(commit); | ||
return IsDirectMergeFromCommit(tag, commit); | ||
} | ||
} | ||
|
||
return base.IsValidTag(branchName, tag, commit); | ||
return base.IsValidTag(context, branchName, tag, commit); | ||
} | ||
|
||
static bool IsDirectMergeFromCommit(Tag tag, Commit commit) | ||
{ | ||
var targetCommit = tag.Target as Commit; | ||
if (targetCommit != null) | ||
{ | ||
var parents = targetCommit.Parents; | ||
if (parents != null) | ||
{ | ||
return parents | ||
.Where(parent => parent != null) | ||
.Any(parent => string.Equals(parent.Id.Sha, commit.Id.Sha, StringComparison.OrdinalIgnoreCase)); | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters