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

(#2304) Make list --exact --all-versions to filter out prereleases by default #2308

Merged

Conversation

vexx32
Copy link
Member

@vexx32 vexx32 commented Aug 2, 2021

Due to a prior fix in the logic for list -e -a, all packages with the target ID were being returned, regardless of whether the user uses the --pre flag or not. Since the same search without --exact does not return prerelease versions unless the --pre option is also passed, the behaviour for list -e -a should match this.

This fix modifies the search logic used when listing all package versions with --exact to also check for and respect the --pre flag from the configuration context, much like other list commands use the setting in this file in other places.

Changes

  • (breaking) choco list $x --all --exact no longer lists prerelease packages by default
  • choco list $x --all --exact --pre lists everything, prereleases included

Fixes #2304

Manual Testing / Verification

You can either build choco from this branch or modify the configuration in VS to start choco in debug mode with specific arguments. You will need to ensure you have access to the community repository in your configuration (and ideally nothing else, for the purposes of this particular test).

  • Run choco with arguments list python3 --exact --all
  • Verify all packages returned are stable (non-prerelease) versions
  • Run choco with arguments list python3 --exact --all --pre
  • Verify:
    • The second command returns many more packages than the first.
    • The second command includes the results from the first command + prerelease versions of the same package.
  • Run choco with arguments list python3 --exact
  • The latest stable version of python3 should be returned.
  • Run choco with arguments list python3 --exact --pre
  • The latest pre-release or stable version of python3 should be returned.
  • Confirm results by checking the python3 package page on the Community Repository and the versions currently available.

@CLAassistant
Copy link

CLAassistant commented Aug 2, 2021

CLA assistant check
All committers have signed the CLA.

@vexx32 vexx32 requested review from AdmiringWorm and gep13 August 2, 2021 13:35
@vexx32
Copy link
Member Author

vexx32 commented Aug 2, 2021

Hrm, seems like the underlying Nuget lib doesn't like the resulting OData query here. Marking this as WIP until I have had a better look.

@vexx32 vexx32 changed the title (#2304) Make list --exact --all-versions to filter out prereleases by default WIP: (#2304) Make list --exact --all-versions to filter out prereleases by default Aug 2, 2021
@vexx32
Copy link
Member Author

vexx32 commented Aug 2, 2021

I have a solution for this, but leaving in WIP for now as we have some decisions to make. Before the changes that affected this command went in, in 0.10.13 the behaviour was:

  • choco list --exact --all lists ALL packages, prereleases included.
  • choco list --all lists no prereleases at all, but also misses many of the packages that --exact finds.

In other words, the problem this addresses was already in 0.10.13 before we made the recent breaks and fixes to the command logic. Will be following up internally to confirm this is the right avenue to go for fixing this issue, and will need to verify whether the issue with --all without --exact has another ticket already assigned, or we need to file another.

I'll push some additional changes shortly that will have this functional, but I expect we'll also want to add some tests around the expected behaviour here before we call this sorted, once a decision is made internally.

@vexx32 vexx32 force-pushed the 2304/list-exact-all-filter-prereleases branch from 5be2fd4 to e7e1249 Compare August 2, 2021 15:43
@vexx32 vexx32 force-pushed the 2304/list-exact-all-filter-prereleases branch from e7e1249 to fcc7f84 Compare August 10, 2021 21:42
@vexx32 vexx32 changed the title WIP: (#2304) Make list --exact --all-versions to filter out prereleases by default (#2304) Make list --exact --all-versions to filter out prereleases by default Aug 10, 2021
@vexx32
Copy link
Member Author

vexx32 commented Aug 10, 2021

To follow up on my previous comment:

  • After following up with the team internally, the determination was that:
    • choco list $x -e -a should list non-prerelease versions only
    • choco list $a -e -a --pre should be respected and allow listing prerelease versions

We acknowledge this is a departure from established behaviour for this specific case (it was the same even back to 0.10.13, and likely earlier). This will make the choco list --exact --all cases behave similarly to other list command functions which don't retrieve prereleases without the --pre switch.

@gep13 I think this one is ready for review. I haven't gone too wild adding test cases, but I have added tests for the specific cases this should affect. Let me know what other cases we want to add here, if any.

@pauby pauby marked this pull request as draft August 11, 2021 09:07
@pauby
Copy link
Member

pauby commented Aug 11, 2021

Converting this to Draft until I can have a conversation about it.

@pauby
Copy link
Member

pauby commented Aug 12, 2021

Conversations had, removing it from Draft.

@pauby pauby marked this pull request as ready for review August 12, 2021 15:04
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.

Minor nit-pick, but otherwise, LGTM!

@@ -496,8 +496,8 @@ public void should_contain_debugging_messages()
MockLogger.contains_message("Start of List", LogLevel.Debug).ShouldBeTrue();
MockLogger.contains_message("End of List", LogLevel.Debug).ShouldBeTrue();
}
}

}
Copy link
Member

Choose a reason for hiding this comment

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

Would prefer to see this whitespace change in a standalone commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorted!

@vexx32 vexx32 force-pushed the 2304/list-exact-all-filter-prereleases branch from fcc7f84 to f1704e8 Compare August 12, 2021 15:29
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!

vexx32 added 2 commits August 19, 2021 07:17
Due to a prior fix in the logic for `list -e -a`, all packages with the
target ID were being returned, regardless of whether the user uses the
`--pre` flag or not. Since the same search without `--exact` does not
return prerelease versions unless the `--pre` option is also passed, the
behaviour for `list -e -a` should match this.

This fix modifies the search logic used when listing all package
versions with `--exact` to also check for and respect the `--pre` flag
from the configuration context, much like other list commands use the
setting in this file in other places.

Also includes a minor refactor to avoid doing a double query here; now
we only call the Search() function if we're actually going to use those
results. The code paths for AllVersions completely discard that already,
so this just removes the need to call the method unnecessarily.
@gep13 gep13 force-pushed the 2304/list-exact-all-filter-prereleases branch from f1704e8 to 50a21c4 Compare August 19, 2021 06:18
@gep13 gep13 changed the base branch from master to stable August 19, 2021 06:18
@gep13
Copy link
Member

gep13 commented Aug 19, 2021

@vexx32 I have switched this PR to target the stable branch, and I will merge once the CI builds finish.

@gep13 gep13 merged commit 85d522f into chocolatey:stable Aug 19, 2021
@gep13
Copy link
Member

gep13 commented Aug 19, 2021

@vexx32 thanks for getting this fixed up!

@vexx32 vexx32 deleted the 2304/list-exact-all-filter-prereleases branch August 31, 2021 21:29
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.

choco list -e -a returns pre-releases even when --pre is not passed
4 participants