Skip to content
This repository was archived by the owner on Sep 20, 2022. It is now read-only.

Commit 2ad076d

Browse files
author
Jake Ginnivan
committed
Allows parsing of commit ranges which are links
1 parent 93a9fff commit 2ad076d

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/GitReleaseNotes/SemanticReleaseNotes.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class SemanticReleaseNotes
1111
{
1212
//readonly Regex _issueRegex = new Regex(" - (?<Issue>.*?)(?<IssueLink> \\[(?<IssueId>.*?)\\]\\((?<IssueUrl>.*?)\\))*( *\\+(?<Tag>[^ \\+]*))*", RegexOptions.Compiled);
1313
static readonly Regex ReleaseRegex = new Regex("# (?<Title>.*?)( \\((?<Date>.*?)\\))?$", RegexOptions.Compiled);
14+
static readonly Regex LinkRegex = new Regex(@"\[(?<Text>.*?)\]\((?<Link>.*?)\)$", RegexOptions.Compiled);
1415
readonly string[] categories;
1516
readonly SemanticRelease[] releases;
1617

@@ -105,7 +106,14 @@ public static SemanticReleaseNotes Parse(string releaseNotes)
105106
}
106107
else if (line.StartsWith("Commits: "))
107108
{
108-
var commits = line.Replace("Commits: ", string.Empty).Split(new[] { "..." }, StringSplitOptions.None);
109+
var commitText = line.Replace("Commits: ", string.Empty);
110+
var linkMatch = LinkRegex.Match(commitText);
111+
if (linkMatch.Success)
112+
{
113+
commitText = linkMatch.Groups["Text"].Value;
114+
currentRelease.DiffInfo.DiffUrlFormat = linkMatch.Groups["Link"].Value;
115+
}
116+
var commits = commitText.Split(new[] { "..." }, StringSplitOptions.None);
109117
currentRelease.DiffInfo.BeginningSha = commits[0];
110118
currentRelease.DiffInfo.EndSha = commits[1];
111119
}

0 commit comments

Comments
 (0)