Skip to content

Commit de4469e

Browse files
committed
simplify ReleaseDateFinder
1 parent c899ce3 commit de4469e

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

GitVersionCore/ReleaseDateFinder.cs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Generic;
2-
using System.Diagnostics;
32
using System.Linq;
43
using LibGit2Sharp;
54

@@ -28,13 +27,12 @@ public static ReleaseDate Execute(IRepository repo, Commit commit, int calculate
2827
}
2928

3029
var vp = FindLatestStableTaggedCommitReachableFrom(repo, commit);
31-
var latestStable = repo.Lookup<Commit>(vp.CommitSha);
32-
rd.OriginalDate = latestStable.When();
33-
rd.OriginalCommitSha = vp.CommitSha;
30+
rd.OriginalDate = vp.When();
31+
rd.OriginalCommitSha = vp.Sha;
3432
return rd;
3533
}
3634

37-
static VersionPoint FindLatestStableTaggedCommitReachableFrom(IRepository repo, Commit commit)
35+
static Commit FindLatestStableTaggedCommitReachableFrom(IRepository repo, Commit commit)
3836
{
3937
var masterTip = repo.FindBranch("master").Tip;
4038
var ancestor = repo.Commits.FindMergeBase(masterTip, commit);
@@ -59,7 +57,7 @@ static VersionPoint FindLatestStableTaggedCommitReachableFrom(IRepository repo,
5957
return null;
6058
}
6159

62-
static VersionPoint RetrieveStableVersionPointFor(IEnumerable<Tag> allTags, Commit c)
60+
static Commit RetrieveStableVersionPointFor(IEnumerable<Tag> allTags, Commit c)
6361
{
6462
var tags = allTags
6563
.Where(tag => tag.PeeledTarget() == c)
@@ -80,7 +78,7 @@ static VersionPoint RetrieveStableVersionPointFor(IEnumerable<Tag> allTags, Comm
8078
var stableTag = tags.Single();
8179
var commit = RetrieveMergeCommit(stableTag);
8280

83-
return BuildFrom(stableTag, commit);
81+
return commit;
8482
}
8583

8684
static bool IsStableRelease(string tagName)
@@ -101,21 +99,6 @@ static Commit RetrieveMergeCommit(Tag stableTag)
10199
throw new WarningException(message);
102100
}
103101

104-
static VersionPoint BuildFrom(Tag stableTag, Commit commit)
105-
{
106-
ShortVersion shortVersion;
107-
108-
var hasParsed = ShortVersionParser.TryParseMajorMinor(stableTag.Name, out shortVersion);
109-
Debug.Assert(hasParsed);
110-
111-
return new VersionPoint
112-
{
113-
Major = shortVersion.Major,
114-
Minor = shortVersion.Minor,
115-
CommitSha = commit.Id.Sha,
116-
};
117-
}
118-
119102

120103
}
121104
}

0 commit comments

Comments
 (0)