-
Notifications
You must be signed in to change notification settings - Fork 3
/
ReleaseHelpers.cs
33 lines (28 loc) · 1.03 KB
/
ReleaseHelpers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace FakeItEasy.Tools;
using System.Globalization;
using System.Text.RegularExpressions;
using Octokit;
internal static class ReleaseHelpers
{
public static ICollection<int> GetIssueNumbersReferencedFromReleases(IEnumerable<Release> releases)
{
if (releases is null)
{
throw new ArgumentNullException(nameof(releases));
}
var issuesReferencedFromRelease = new HashSet<int>();
foreach (var release in releases)
{
foreach (var capture in Regex.Matches(release.Body, @"\(\s*#(?<issueNumber>[0-9]+)(,\s*#(?<issueNumber>[0-9]+))*\s*\)")
.SelectMany(match => match.Groups["issueNumber"].Captures))
{
issuesReferencedFromRelease.Add(int.Parse(capture.Value, NumberStyles.Integer, NumberFormatInfo.InvariantInfo));
}
}
return issuesReferencedFromRelease;
}
public static bool IsPreRelease(string version)
{
return version.Contains('-', StringComparison.Ordinal);
}
}