Skip to content

Commit 8c734dd

Browse files
Support PRs without issues as changes, simplify API with batched operations (#22)
* Initial plan * Rename IssueInfo to ChangeInfo and add GetChangesBetweenTagsAsync method Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Rename properties: ChangeIssues→Changes, BugIssues→Bugs Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Add test for PRs without issues and fix affected tests Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Update GetOpenIssuesAsync to return ChangeData with batched fetching Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Remove old methods from IRepoConnector and implementations Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Remove tests for deleted methods Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Merge ChangeData into ChangeInfo by adding Type property Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Rename ChangeInfo to ItemInfo for better semantic accuracy Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Move ItemInfo record to its own file Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Remove --jq from all gh commands to avoid shell quoting issues Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Add using System.Text.Json directive to simplify code Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Fix issue title fetching by batch loading all issues via gh issue list Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Fix code quality/lint issues: formatting and spelling Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
1 parent e672a6b commit 8c734dd

File tree

10 files changed

+521
-978
lines changed

10 files changed

+521
-978
lines changed

src/DemaConsulting.BuildMark/BuildInformation.cs

Lines changed: 38 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,24 @@
2020

2121
namespace DemaConsulting.BuildMark;
2222

23-
/// <summary>
24-
/// Represents information about an issue.
25-
/// </summary>
26-
/// <param name="Id">Issue ID.</param>
27-
/// <param name="Title">Issue title.</param>
28-
/// <param name="Url">Issue URL.</param>
29-
public record IssueInfo(string Id, string Title, string Url);
30-
3123
/// <summary>
3224
/// Represents build information for a release.
3325
/// </summary>
3426
/// <param name="FromVersion">Starting version (null if from beginning of history).</param>
3527
/// <param name="ToVersion">Ending version.</param>
3628
/// <param name="FromHash">Starting git hash (null if from beginning of history).</param>
3729
/// <param name="ToHash">Ending git hash.</param>
38-
/// <param name="ChangeIssues">Non-bug changes performed between versions.</param>
39-
/// <param name="BugIssues">Bugs fixed between versions.</param>
30+
/// <param name="Changes">Non-bug changes performed between versions.</param>
31+
/// <param name="Bugs">Bugs fixed between versions.</param>
4032
/// <param name="KnownIssues">Known issues (unfixed or fixed but not in this build).</param>
4133
public record BuildInformation(
4234
Version? FromVersion,
4335
Version ToVersion,
4436
string? FromHash,
4537
string ToHash,
46-
List<IssueInfo> ChangeIssues,
47-
List<IssueInfo> BugIssues,
48-
List<IssueInfo> KnownIssues)
38+
List<ItemInfo> Changes,
39+
List<ItemInfo> Bugs,
40+
List<ItemInfo> KnownIssues)
4941
{
5042
/// <summary>
5143
/// Creates a BuildInformation record from a repository connector.
@@ -158,67 +150,50 @@ public static async Task<BuildInformation> CreateAsync(IRepoConnector connector,
158150
}
159151
}
160152

161-
// Collect all pull requests and their associated issues in version range
162-
var pullRequests = await connector.GetPullRequestsBetweenTagsAsync(fromTagInfo, toTagInfo);
163-
var allIssues = new HashSet<string>();
164-
var bugIssues = new List<IssueInfo>();
165-
var changeIssues = new List<IssueInfo>();
153+
// Collect all changes (issues and PRs) in version range
154+
var changes = await connector.GetChangesBetweenTagsAsync(fromTagInfo, toTagInfo);
155+
var allChangeIds = new HashSet<string>();
156+
var bugs = new List<ItemInfo>();
157+
var nonBugChanges = new List<ItemInfo>();
166158

167-
// Process each pull request to extract and categorize issues
168-
foreach (var pr in pullRequests)
159+
// Process and categorize each change
160+
foreach (var change in changes)
169161
{
170-
// Get all issues referenced by this pull request
171-
var issueIds = await connector.GetIssuesForPullRequestAsync(pr);
172-
173-
foreach (var issueId in issueIds)
162+
// Skip changes already processed
163+
if (allChangeIds.Contains(change.Id))
174164
{
175-
// Skip issues already processed
176-
if (allIssues.Contains(issueId))
177-
{
178-
continue;
179-
}
180-
181-
// Mark issue as processed
182-
allIssues.Add(issueId);
183-
184-
// Fetch issue details
185-
var title = await connector.GetIssueTitleAsync(issueId);
186-
var url = await connector.GetIssueUrlAsync(issueId);
187-
var type = await connector.GetIssueTypeAsync(issueId);
165+
continue;
166+
}
188167

189-
// Create issue record
190-
var issueInfo = new IssueInfo(issueId, title, url);
168+
// Mark change as processed
169+
allChangeIds.Add(change.Id);
191170

192-
// Categorize issue by type
193-
if (type == "bug")
194-
{
195-
bugIssues.Add(issueInfo);
196-
}
197-
else
198-
{
199-
changeIssues.Add(issueInfo);
200-
}
171+
// Categorize change by type
172+
if (change.Type == "bug")
173+
{
174+
bugs.Add(change);
175+
}
176+
else
177+
{
178+
nonBugChanges.Add(change);
201179
}
202180
}
203181

204182
// Collect known issues (open bugs not fixed in this build)
205-
var knownIssues = new List<IssueInfo>();
206-
var openIssueIds = await connector.GetOpenIssuesAsync();
207-
foreach (var issueId in openIssueIds)
183+
var knownIssues = new List<ItemInfo>();
184+
var openIssues = await connector.GetOpenIssuesAsync();
185+
foreach (var issue in openIssues)
208186
{
209187
// Skip issues already fixed in this build
210-
if (allIssues.Contains(issueId))
188+
if (allChangeIds.Contains(issue.Id))
211189
{
212190
continue;
213191
}
214192

215193
// Only include bugs in known issues list
216-
var type = await connector.GetIssueTypeAsync(issueId);
217-
if (type == "bug")
194+
if (issue.Type == "bug")
218195
{
219-
var title = await connector.GetIssueTitleAsync(issueId);
220-
var url = await connector.GetIssueUrlAsync(issueId);
221-
knownIssues.Add(new IssueInfo(issueId, title, url));
196+
knownIssues.Add(issue);
222197
}
223198
}
224199

@@ -228,8 +203,8 @@ public static async Task<BuildInformation> CreateAsync(IRepoConnector connector,
228203
toTagInfo,
229204
fromHash?.Trim(),
230205
toHash.Trim(),
231-
changeIssues,
232-
bugIssues,
206+
nonBugChanges,
207+
bugs,
233208
knownIssues);
234209
}
235210

@@ -276,9 +251,9 @@ public string ToMarkdown(int headingDepth = 1, bool includeKnownIssues = false)
276251
markdown.AppendLine();
277252
markdown.AppendLine("| Issue | Title |");
278253
markdown.AppendLine("|-------|-------|");
279-
if (ChangeIssues.Count > 0)
254+
if (Changes.Count > 0)
280255
{
281-
foreach (var issue in ChangeIssues)
256+
foreach (var issue in Changes)
282257
{
283258
markdown.AppendLine($"| [{issue.Id}]({issue.Url}) | {issue.Title} |");
284259
}
@@ -294,9 +269,9 @@ public string ToMarkdown(int headingDepth = 1, bool includeKnownIssues = false)
294269
markdown.AppendLine();
295270
markdown.AppendLine("| Issue | Title |");
296271
markdown.AppendLine("|-------|-------|");
297-
if (BugIssues.Count > 0)
272+
if (Bugs.Count > 0)
298273
{
299-
foreach (var issue in BugIssues)
274+
foreach (var issue in Bugs)
300275
{
301276
markdown.AppendLine($"| [{issue.Id}]({issue.Url}) | {issue.Title} |");
302277
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) DEMA Consulting
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in all
11+
// copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
// SOFTWARE.
20+
21+
namespace DemaConsulting.BuildMark;
22+
23+
/// <summary>
24+
/// Represents an item in the build notes (change, bug, or known issue).
25+
/// </summary>
26+
/// <param name="Id">Item ID.</param>
27+
/// <param name="Title">Item title.</param>
28+
/// <param name="Url">Item URL.</param>
29+
/// <param name="Type">Item type (bug, feature, etc.).</param>
30+
public record ItemInfo(string Id, string Title, string Url, string Type);

src/DemaConsulting.BuildMark/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ private static void ProcessBuildNotes(Context context)
192192
context.WriteLine($"Previous Version: {buildInfo.FromVersion.Tag}");
193193
context.WriteLine($"Previous Commit Hash: {buildInfo.FromHash}");
194194
}
195-
context.WriteLine($"Changes: {buildInfo.ChangeIssues.Count}");
196-
context.WriteLine($"Bugs Fixed: {buildInfo.BugIssues.Count}");
195+
context.WriteLine($"Changes: {buildInfo.Changes.Count}");
196+
context.WriteLine($"Bugs Fixed: {buildInfo.Bugs.Count}");
197197
context.WriteLine($"Known Issues: {buildInfo.KnownIssues.Count}");
198198

199199
// Export markdown report if requested

0 commit comments

Comments
 (0)