Skip to content

Commit 66592d4

Browse files
committed
Inlined RecentTagVersionExtractor into only class using it
1 parent 2f7a666 commit 66592d4

File tree

3 files changed

+20
-31
lines changed

3 files changed

+20
-31
lines changed

GitVersionCore/GitFlow/BranchFinders/RecentTagVersionExtractor.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

GitVersionCore/GitVersionCore.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
<Compile Include="Configuration\LegacyConfigNotifier.cs" />
8181
<Compile Include="Configuration\OldConfigurationException.cs" />
8282
<Compile Include="EffectiveConfiguration.cs" />
83-
<Compile Include="GitFlow\BranchFinders\RecentTagVersionExtractor.cs" />
8483
<Compile Include="Helpers\FileSystem.cs" />
8584
<Compile Include="Helpers\IFileSystem.cs" />
8685
<Compile Include="Helpers\ProcessHelper.cs" />
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
namespace GitVersion.VersioningModes
22
{
33
using System.Collections.Generic;
4-
4+
using System.Linq;
55
using LibGit2Sharp;
66

77
public class ContinuousDeliveryMode : VersioningModeBase
88
{
99
public override SemanticVersionPreReleaseTag GetPreReleaseTag(GitVersionContext context, List<Tag> possibleCommits, int numberOfCommits)
1010
{
11-
return RecentTagVersionExtractor.RetrieveMostRecentOptionalTagVersion(context, possibleCommits)
12-
?? context.Configuration.Tag + ".1";
11+
return RetrieveMostRecentOptionalTagVersion(context, possibleCommits) ?? context.Configuration.Tag + ".1";
12+
}
13+
14+
static SemanticVersionPreReleaseTag RetrieveMostRecentOptionalTagVersion(GitVersionContext context, List<Tag> applicableTagsInDescendingOrder)
15+
{
16+
if (applicableTagsInDescendingOrder.Any())
17+
{
18+
var taggedCommit = applicableTagsInDescendingOrder.First().Target;
19+
var preReleaseVersion = applicableTagsInDescendingOrder.Select(tag => SemanticVersion.Parse(tag.Name, context.Configuration.GitTagPrefix)).FirstOrDefault();
20+
if (preReleaseVersion != null)
21+
{
22+
if (taggedCommit != context.CurrentCommit)
23+
{
24+
preReleaseVersion.PreReleaseTag.Number++;
25+
}
26+
return preReleaseVersion.PreReleaseTag;
27+
}
28+
}
29+
return null;
1330
}
1431
}
1532
}

0 commit comments

Comments
 (0)