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

upgrade - add a way to downgrade from prerelease to the latest official version #2685

Open
Zieleslaw opened this issue Apr 11, 2022 · 1 comment

Comments

@Zieleslaw
Copy link

I sometimes upgrade my company's package on my PC to prerelease version (for a review etc.) and then I want to bring official version back. I have two options:

  • Uninstalling and installing the package again without --pre flag (performs scripts even if I already am on official version),
  • Upgrading to specific official version (requires checking version's number).

I would like to have the third option without drawbacks of the two above, going something like:
choco upgrade package-name --allow-downgrade --exclude-prerelease
Current:

package-name v1.0.1-pre is newer than the most recent.
You must be smarter than the average bear...

Expected:

You have package-name v1.0.1-pre installed. Version 1.0.0 is available based on your source(s).

Another flag like "official-only" would also work for me.
Discussion in #686 makes sense to me, but refers to situation when before upgrade there is a package installed that is older than the latest official. In my case, installed package is newer than the latest official.

@Zieleslaw
Copy link
Author

As far as I can tell, it's all about this line: https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/services/NugetService.cs#L745
if (installedPackage.Version > availablePackage.Version && (!config.AllowDowngrade || (config.AllowDowngrade && version == null)))

If we had config parameter RestoreOfficial for Choco Upgrade, it would look like:
if (installedPackage.Version > availablePackage.Version && (!config.AllowDowngrade || (config.AllowDowngrade && version == null && !config.RestoreOfficial)))
Thanks to this change, following line can execute: https://github.com/chocolatey/choco/blob/develop/src/chocolatey/infrastructure.app/services/NugetService.cs#L795

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants