Skip to content

Commit e9a596e

Browse files
CopilotMalcolmnixon
andcommitted
Fix issue linking and open PR inclusion in build notes
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
1 parent 10df2e7 commit e9a596e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/DemaConsulting.BuildMark/RepoConnectors/GitHubRepoConnector.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,21 @@ public override async Task<BuildInformation> GetBuildInformationAsync(Version? v
8080

8181
// Build a mapping from commit SHA to pull request.
8282
// This is used to associate commits with their pull requests for change tracking.
83-
var commitHashToPr = pullRequests
84-
.Where(p => p.Merged && p.MergeCommitSha != null)
85-
.ToDictionary(p => p.MergeCommitSha!, p => p);
83+
// Include both merged PRs (via MergeCommitSha) and open PRs (via head SHA).
84+
var commitHashToPr = new Dictionary<string, PullRequest>();
85+
foreach (var pr in pullRequests)
86+
{
87+
if (pr.Merged && pr.MergeCommitSha != null)
88+
{
89+
// Add merged PR by its merge commit SHA
90+
commitHashToPr.TryAdd(pr.MergeCommitSha, pr);
91+
}
92+
else if (pr.State == ItemState.Open && pr.Head?.Sha != null)
93+
{
94+
// Add open PR by its head commit SHA
95+
commitHashToPr.TryAdd(pr.Head.Sha, pr);
96+
}
97+
}
8698

8799
// Build a set of commit SHAs in the current branch.
88100
// This is used for efficient filtering of branch-related tags.
@@ -232,8 +244,8 @@ public override async Task<BuildInformation> GetBuildInformationAsync(Version? v
232244
{
233245
// Find issues that are linked to this PR
234246
// Use Issue.PullRequest.HtmlUrl to match with PullRequest.HtmlUrl
247+
// Include both open and closed issues referenced by the PR
235248
var linkedIssues = issues.Where(i =>
236-
i.State == ItemState.Closed &&
237249
i.PullRequest != null &&
238250
i.PullRequest.HtmlUrl == pr.HtmlUrl).ToList();
239251

0 commit comments

Comments
 (0)