Skip to content

feat(cli): Add component identity-diff command, scenario test#49

Draft
dmcilvaney wants to merge 1 commit intomicrosoft:mainfrom
dmcilvaney:damcilva/component_change_detection_parts/7
Draft

feat(cli): Add component identity-diff command, scenario test#49
dmcilvaney wants to merge 1 commit intomicrosoft:mainfrom
dmcilvaney:damcilva/component_change_detection_parts/7

Conversation

@dmcilvaney
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 31, 2026 00:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new CLI workflow for comparing component identity outputs, intended to support CI/build-queue determination by diffing two identity JSON files.

Changes:

  • Introduces azldev component diff-identity command to compare two identity JSON files and emit changed/added/removed/unchanged sets.
  • Adds unit tests for diff computation and file parsing behaviors.
  • Adds scenario coverage and generated CLI documentation updates for the new command (plus a new developer reference doc).

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/app/azldev/cmds/component/diffidentity.go New component diff-identity command implementation and diff logic.
internal/app/azldev/cmds/component/diffidentity_test.go Unit tests for diff logic and JSON/table output behavior.
internal/app/azldev/cmds/component/component.go Registers the new diff-identity subcommand under component.
scenario/component_identity_test.go New scenario tests exercising identity/diff-identity CLI behavior in help mode and in-container flow.
scenario/__snapshots__/*TestComponentIdentitySnapshots* New snapshots for component identity --help and component diff-identity --help.
docs/user/reference/cli/azldev_component.md Adds diff-identity to generated component command index.
docs/user/reference/cli/azldev_component_diff-identity.md Generated CLI docs for the new diff-identity command.
docs/developer/reference/component-identity.md Developer-facing explanation of identity + diff-identity workflow and fingerprint inputs.

Comment on lines +110 to +125
data, err := fileutils.ReadFile(env.FS(), filePath)
if err != nil {
return nil, fmt.Errorf("reading file:\n%w", err)
}

var entries []ComponentIdentityResult

err = json.Unmarshal(data, &entries)
if err != nil {
return nil, fmt.Errorf("parsing JSON:\n%w", err)
}

result := make(map[string]string, len(entries))
for _, entry := range entries {
result[entry.Component] = entry.Fingerprint
}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

readIdentityFile unmarshals into []ComponentIdentityResult, but that type is not defined anywhere in the repo (searching the whole tree only finds this reference). This will fail to compile. Define a local struct matching the on-disk JSON schema (e.g., fields for component and fingerprint) or import/rename to the actual identity entry type used by component identity output.

Copilot uses AI. Check for mistakes.
Comment on lines +32 to +35
"identity help": cmdtest.NewScenarioTest("component", "identity", "--help").Locally(),
"diff-identity help": cmdtest.NewScenarioTest("component", "diff-identity", "--help").Locally(),
}

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

This scenario test (and the added snapshots) invoke azldev component identity --help, but there is no component identity command registered anywhere in internal/app/azldev/cmds/ (only diff-identity, diff-sources, add, build, list, prepare-sources, query). As-is, the scenario test should fail with an unknown command error. Either add/register the component identity Cobra command in the CLI, or update the scenario test/snapshots to target the actual command name.

Suggested change
"identity help": cmdtest.NewScenarioTest("component", "identity", "--help").Locally(),
"diff-identity help": cmdtest.NewScenarioTest("component", "diff-identity", "--help").Locally(),
}
"diff-identity help": cmdtest.NewScenarioTest("component", "diff-identity", "--help").Locally(),
}

Copilot uses AI. Check for mistakes.
@dmcilvaney dmcilvaney marked this pull request as draft March 31, 2026 01:42
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

Successfully merging this pull request may close these issues.

2 participants