-
Notifications
You must be signed in to change notification settings - Fork 80
Group dependencies by version range in backflow PR descriptions #4991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two cases where you should remove a new line in the test strings in order to make the test pass
test/ProductConstructionService.DependencyFlow.Tests/PullRequestBuilderTests.cs
Show resolved
Hide resolved
test/ProductConstructionService.DependencyFlow.Tests/PullRequestBuilderTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
src/ProductConstructionService/ProductConstructionService.DependencyFlow/PullRequestBuilder.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: premun <7013027+premun@users.noreply.github.com>
@@ -407,10 +407,28 @@ internal static string CreateDependencyUpdateBlock( | |||
{ | |||
stringBuilder.AppendLine(); | |||
stringBuilder.AppendLine("**Updated Dependencies**"); | |||
foreach (DependencyUpdateSummary depUpdate in dependencyCategories.UpdatedDependencies) | |||
|
|||
// Group dependencies by version range and commit range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is great, but there's an issue. You implemented the grouping only for updated dependencies. Sorry if I wasn't clear about it, but all changes in dependencies should have this "grouped" formatting - including RemovedDependencies
and AddedDependencies
- not just UpdatedDependencies
.
Please also add a test to reflect this - where there's a bunch of dependency changes of all 3 types: additions, removals, and version updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extended the grouping functionality to all dependency types (New, Removed, Updated) as requested. Dependencies are now grouped by version and commit for all three categories, with alphabetical sorting within each group. Added a comprehensive test case that covers multiple dependencies of each type to verify the functionality works correctly. (d7eef5e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look, that's great and it works, but I don't like that we are almost duplicating the same grouping functionality 3 times. I think we should be able to do the grouping logic just one time on the entire list of dependency changes. Maybe that would require modifying or even getting rid of the method CreateDependencyCategories
, I don't know. But I think that grouping by FromCommitSha, FromVersion, ToCommitSha, and ToVersion just like you did, should cover the cases of grouping for all 3 types of dependency changes (additions, removals, and updates)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored to use a unified grouping approach that eliminates code duplication. All dependencies are now grouped by FromCommitSha
, FromVersion
, ToCommitSha
, and ToVersion
in a single operation, then separated by type based on which values are null/empty. This removes the three separate grouping blocks and the CreateDependencyCategories
method. (615219d)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good. Let's go one step further: I think GetLinkForDependencyItem
can be refactored a bit so it just takes the repoUri, an "old" commit sha and a "new" commit sha. No need to take a DependencyUpdateSummary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored GetLinkForDependencyItem
to take repoUri
, fromCommitSha
, and toCommitSha
as separate parameters instead of DependencyUpdateSummary
. Updated all call sites accordingly. (88a18c6)
…comprehensive tests Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
… duplication Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
{ | ||
stringBuilder.AppendLine(); | ||
stringBuilder.AppendLine("**New Dependencies**"); | ||
foreach (DependencyUpdateSummary depUpdate in dependencyCategories.NewDependencies) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed extra blank line. (88a18c6)
{ | ||
stringBuilder.AppendLine(); | ||
stringBuilder.AppendLine("**Removed Dependencies**"); | ||
foreach (DependencyUpdateSummary depUpdate in dependencyCategories.RemovedDependencies) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed extra blank line. (88a18c6)
IReadOnlyCollection<DependencyUpdateSummary> RemovedDependencies, | ||
IReadOnlyCollection<DependencyUpdateSummary> UpdatedDependencies | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed extra blank lines. (88a18c6)
.ToList(); | ||
|
||
// Separate groups by dependency type | ||
var newDependencyGroups = dependencyGroups.Where(g => string.IsNullOrEmpty(g.Key.FromVersion)).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it more explicit:
var newDependencyGroups = dependencyGroups.Where(g => string.IsNullOrEmpty(g.Key.FromVersion)).ToList(); | |
var newDependencyGroups = dependencyGroups.Where(g => string.IsNullOrEmpty(g.Key.FromVersion) && !string.IsNullOrEmpty(g.Key.ToVersion)).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the dependency filtering explicit by checking both conditions: string.IsNullOrEmpty(g.Key.FromVersion) && !string.IsNullOrEmpty(g.Key.ToVersion)
for new dependencies. (88a18c6)
|
||
// Separate groups by dependency type | ||
var newDependencyGroups = dependencyGroups.Where(g => string.IsNullOrEmpty(g.Key.FromVersion)).ToList(); | ||
var removedDependencyGroups = dependencyGroups.Where(g => string.IsNullOrEmpty(g.Key.ToVersion)).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it more explicit:
var removedDependencyGroups = dependencyGroups.Where(g => string.IsNullOrEmpty(g.Key.ToVersion)).ToList(); | |
var removedDependencyGroups = dependencyGroups.Where(g => string.IsNullOrEmpty(g.Key.ToVersion) && !string.IsNullOrEmpty(g.Key.FromVersion)).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made the dependency filtering explicit by checking both conditions: string.IsNullOrEmpty(g.Key.ToVersion) && !string.IsNullOrEmpty(g.Key.FromVersion)
for removed dependencies. (88a18c6)
@@ -407,10 +407,28 @@ internal static string CreateDependencyUpdateBlock( | |||
{ | |||
stringBuilder.AppendLine(); | |||
stringBuilder.AppendLine("**Updated Dependencies**"); | |||
foreach (DependencyUpdateSummary depUpdate in dependencyCategories.UpdatedDependencies) | |||
|
|||
// Group dependencies by version range and commit range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good. Let's go one step further: I think GetLinkForDependencyItem
can be refactored a bit so it just takes the repoUri, an "old" commit sha and a "new" commit sha. No need to take a DependencyUpdateSummary.
…r review feedback Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
This PR implements dependency grouping in backflow PR descriptions to reduce visual noise when multiple packages have the same version update.
Problem
Currently, each dependency update is listed individually with its own link, creating repetitive output:
Solution
Dependencies with the same version range and commit range are now grouped under a single link:
Changes
CreateDependencyUpdateBlock
method to group dependencies by version and commit rangesAppendBuildDescription
method to group dependencies while preserving reference-style linksImplementation Details
Both code paths now:
(FromVersion, ToVersion, FromCommit, ToCommit)
tupleFixes #4983.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.