Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 20, 2025

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:

**Updated Dependencies**
- **Microsoft.TemplateEngine.Abstractions**: [from 10.0.100-preview.6.25317.107 to 10.0.100-preview.6.25318.104][1]
- **Microsoft.TemplateEngine.Edge**: [from 10.0.100-preview.6.25317.107 to 10.0.100-preview.6.25318.104][1]  
- **Microsoft.TemplateEngine.Utils**: [from 10.0.100-preview.6.25317.107 to 10.0.100-preview.6.25318.104][1]

Solution

Dependencies with the same version range and commit range are now grouped under a single link:

**Updated Dependencies**
- From [10.0.100-preview.6.25317.107 to 10.0.100-preview.6.25318.104][1]
  - Microsoft.TemplateEngine.Abstractions
  - Microsoft.TemplateEngine.Edge
  - Microsoft.TemplateEngine.Utils

Changes

  • Codeflow PRs: Modified CreateDependencyUpdateBlock method to group dependencies by version and commit ranges
  • Dependency Flow PRs: Modified AppendBuildDescription method to group dependencies while preserving reference-style links
  • Tests: Added comprehensive tests for both code paths and updated existing test expectations

Implementation Details

Both code paths now:

  1. Group dependencies by (FromVersion, ToVersion, FromCommit, ToCommit) tuple
  2. Display one link per group with the version range
  3. List individual package names under each group
  4. Maintain existing reference-style link functionality where applicable

Fixes #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.

Copilot AI and others added 2 commits June 20, 2025 09:17
Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Declutter the "updated dependencies" section in backflow PRs Group dependencies by version range in backflow PR descriptions Jun 20, 2025
@Copilot Copilot AI requested a review from adamzip June 20, 2025 09:30
Copilot finished work on behalf of adamzip June 20, 2025 09:30
Copy link
Contributor

@adamzip adamzip left a 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

Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
@Copilot Copilot AI requested a review from adamzip June 20, 2025 13:42
Copilot finished work on behalf of adamzip June 20, 2025 13:42
Co-authored-by: premun <7013027+premun@users.noreply.github.com>
@Copilot Copilot AI requested a review from premun June 20, 2025 14:26
Copilot finished work on behalf of premun June 20, 2025 14:26
@premun premun marked this pull request as ready for review June 20, 2025 14:27
@@ -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
Copy link
Contributor

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

Copy link
Contributor Author

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)

Copy link
Contributor

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)

Copy link
Contributor Author

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)

Copy link
Contributor

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.

Copy link
Contributor Author

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>
@Copilot Copilot AI requested a review from adamzip June 20, 2025 14:56
Copilot finished work on behalf of adamzip June 20, 2025 14:56
… duplication

Co-authored-by: adamzip <3237436+adamzip@users.noreply.github.com>
Copilot finished work on behalf of adamzip June 20, 2025 15:11
{
stringBuilder.AppendLine();
stringBuilder.AppendLine("**New Dependencies**");
foreach (DependencyUpdateSummary depUpdate in dependencyCategories.NewDependencies)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Contributor Author

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Contributor Author

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
);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Contributor Author

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();
Copy link
Contributor

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:

Suggested change
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();

Copy link
Contributor Author

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();
Copy link
Contributor

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:

Suggested change
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();

Copy link
Contributor Author

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
Copy link
Contributor

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>
@Copilot Copilot AI requested a review from adamzip June 20, 2025 16:47
Copilot finished work on behalf of adamzip June 20, 2025 16:47
@adamzip adamzip merged commit 7b6990a into main Jun 25, 2025
9 checks passed
@adamzip adamzip deleted the copilot/fix-4983 branch June 25, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Error loading sessions

Retrying...

Successfully merging this pull request may close these issues.

Declutter the "updated dependencies" section in backflow PRs
4 participants