-
Notifications
You must be signed in to change notification settings - Fork 908
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
(#1443) Reset config via action after every package upgrade #2484
Conversation
391a2a6
to
7274b07
Compare
7274b07
to
fc5db8f
Compare
fc5db8f
to
b6d60da
Compare
b6d60da
to
d1d7cff
Compare
d1d7cff
to
61acac5
Compare
61acac5
to
45a572d
Compare
49fec9b
to
3fae5fa
Compare
3fae5fa
to
c6b7dd3
Compare
c6b7dd3
to
ff464f7
Compare
src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs
Outdated
Show resolved
Hide resolved
ff464f7
to
1959747
Compare
It seems like this only remembers bool switches (like
And during that |
Hmm, that sounds like we would maybe want to wait to pull this PR into the repository. I'll bring it up internally tomorrow to see where we want to go. EDIT: I have a nagging feeling it is not just boolean switches, but rather everything once it goes to the second package. |
I have had a chat internally about this, and we have come up with a solution that I will be trying out. Expect this PR to be updated with the new code that I have in mind that should allow us to have a clean copy of the Configuration class, while still being able to retain the references that are required to be in place (the references are the identified cause of the issue that makes Chocolatey CLI forget about the needed arguments for further package executions). |
I have moved this PR into draft, while the code and tests are being worked on to prevent any merges happening |
2edef72
to
70a2b07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few spelling points in the comments.
Also a question: Does this need to be updated in chocolatey licensed extension as well?
src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs
Outdated
Show resolved
Hide resolved
src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs
Outdated
Show resolved
Hide resolved
src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs
Outdated
Show resolved
Hide resolved
src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs
Outdated
Show resolved
Hide resolved
No, there is no need to update anything in the Licensed codebase. |
4fa6640
to
8d0e7ed
Compare
This commit adds two new methods to the Chocolatey Configuration class that will be used to create a backup of the current values inside the Config class, without these being able to be changed. Once requested and the backup exists, we are then able to reset the Config file without loosing the reference to the class. This was something that is needed, as we rely in several places that the reference is updatable throughout the entire Chocolatey CLI codebase. This also means we can not replace the reference to the Config file itself without loosing the ability to make use of remembered arguments when multiple packages requires these to be used.
This updates the action used when handling package results during upgrade to reset the configuration class that is initially set. This fixes a bug when useRememberedArguments is enabled that causes arguments to be reused in the chocolateyInstall.ps1 when multiple packages are upgraded. It happens because OptionSet.parse() sets the configuration via the actions specified in the UpgradeCommand optionSet setup (and likewise in configuration builder as well). It only sets options that are saved, so if a later package does not have an option, it is not set, and the previous option is reused. This fixes the bug because it resets the configuration at the ChocolateyPackageService level, which is enough to reset the configuration for action that runs the PowerShell as well. Co-authored-by: TheCakeIsNaOH <[email protected]>
This commit updates other handlers in the Nuget Service to use the same approach when resetting configuration class as was added when upgrading packages. This allows us to use the same approach in the relevant code paths without having to rely on manually deep copying the reference and thus loosing the actual reference to the configuration object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This commit updates the vagrant image and Invoke-Tests to handle scenarios where tests has been added that should not run outside of one of the virtual machines that we have available.
8d0e7ed
to
8f15337
Compare
Thanks for getting this added @AdmiringWorm. I'll let the GitHub Actions finish, then kick the one that failed and once that's all green I'll get this merged 😁 |
Description Of Changes
This adds a parameter to the upgrade_run method, which
is used to pass an action which resets the configuration in the
function that calls upgrade_run.
Motivation and Context
This fixes a bug when useRememberedArguments is enabled that causes
arguments to be reused in the chocolateyInstall.ps1 when multiple
packages are upgraded. It happens because OptionSet.parse() sets the
configuration via the actions specified in the UpgradeCommand optionSet
setup (and likewise in configuration builder as well). It only sets
options that are saved, so if a later package does not have an option,
it is not set, and the previous option is reused.
This fixes the bug because it resets the configuration at the
ChocolateyPackageService level, which is enough to reset the
configuration for action that runs the PowerShell as well.
Testing
Note that curl has package parameters, install arguments and forcex86 set, while wget does not have any of those.
.\choco.exe upgrade all --allow-unofficial -y --debug
The curl install script should be run with the package parameters, install arguments and forcex86 similar to this:
And the wget install script should be run without those arguments:
Change Types Made
Related Issue
Fixes #1443
Change Checklist