Skip to content
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

(#508) Do case insensitive comparison on package ids #3157

Merged
merged 1 commit into from
May 15, 2023

Conversation

AdmiringWorm
Copy link
Member

@AdmiringWorm AdmiringWorm commented May 15, 2023

Description Of Changes

This pull request updates the Equals comparisons in the NuGet service to be case insensitive.

This is done as without this change the user will always have to pass in the identifier in the exact casing that is returned from the NuGet server, causing issues especially during upgrade scenarios.

Additionally, Equals and Compare methods has been added to the banned API list to prevent the use
of these without specifying a StringComparison.

Motivation and Context

The behaviour in v2.x and 1.x should behave similar, and we should not expect the user to do the work for us to ensure the casing of installed packages, server packages and passed in identifier to be the same casing

Testing

  1. Install the package 7zip using choco install 7ziP --confirm
  2. It should successfully install
  3. Do a noop upgrade using choco upgrade 7Zip --noop -r
  4. Ensure choco outputs 7zip|22.1|22.1|false (there may be additional 0 in the versions)
  5. Try doing an upgrade using choco upgrade 7zIp
  6. Ensure it is outputted that the package is up to date
  7. Uninstall the package again using choco uninstall 7Zip --confirm
  8. Ensure the package was successfully uninstalled

Operating Systems Testing

  • Windows 10

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v2 compatibility checked?

Related Issue

@AdmiringWorm AdmiringWorm requested a review from gep13 May 15, 2023 09:37
@AdmiringWorm AdmiringWorm self-assigned this May 15, 2023
This commit updates the Equals comparisons in the nuget
service to be case insensitive.

This is done as without this change the user will always
have to pass in the identifier in the exact casing that
is returned from the nuget server, causing issues especially
during upgrade scenarios.

Additionally, Equals and Compare methods has been added
to the banned API list to prevent the use
of these without specifying a StringComparison.
Copy link
Member

@gep13 gep13 left a comment

Choose a reason for hiding this comment

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

LGTM!

@gep13 gep13 merged commit e4c9fb6 into chocolatey:release/2.0.0 May 15, 2023
@gep13
Copy link
Member

gep13 commented May 15, 2023

@AdmiringWorm thanks for getting this fixed up!

@AdmiringWorm AdmiringWorm deleted the casing-fixes branch May 16, 2023 22:14
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