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

[Bug] The scoop_* properties in $scoopConfig are invariably removed and re-added #5434

Closed
bradenhilton opened this issue Mar 16, 2023 · 1 comment · Fixed by #5424
Closed
Labels

Comments

@bradenhilton
Copy link

Bug Report

Current Behavior

When iterating through $newConfigNames in lib/core.ps1, the method of accessing the value in $scoopConfig by key is not case-sensitive. This results in the scoop_* properties being removed and re-added, even if they are already using the new naming convention.

Expected Behavior

I expect that $scoopConfig is left untouched if it already contains the new property names (snake_case instead of SCREAMING_CASE).

Additional context/output

I am managing my Scoop config with chezmoi.

I parse the existing config into an unordered dictionary, edit some values if required, then output the new config to a JSON string. This output JSON invariably has its properties in alphabetical order. There is no trivial way to prevent this.

This would be fine, if, when Scoop updates, it doesn't change any config object properties unless it has to.

With my current config (seen below), if Scoop updates, it changes the config to:

{
  "aria2-enabled": true,
  "aria2-warning-enabled": false,
  "last_update": "2023-03-16T17:40:10.9403059+00:00",
  "use_external_7zip": true,
  "scoop_repo": "https://github.com/ScoopInstaller/Scoop",
  "scoop_branch": "master"
}

This results in a lot of unnecessary diffs.

Possible Solution

Perform a case-sensitive lookup, perhaps something like:

$newConfigNames.GetEnumerator() | ForEach-Object {
    if ($scoopConfig.PSObject.Properties.Name.Contains($_.Key) -and $null -ne $scoopConfig.$($_.Key)) {
        ...
    }
}

If I edit my current config (again, seen below) to use SCOOP_BRANCH instead, this case-sensitive lookup would result in the following config:

{
  "aria2-enabled": true,
  "aria2-warning-enabled": false,
  "last_update": "2023-03-16T17:40:10.9403059+00:00",
  "scoop_repo": "https://github.com/ScoopInstaller/Scoop",
  "use_external_7zip": true,
  "scoop_branch": "master"
}

This would require parsing and outputting again on my end to get it back into alphabetical order. Crucially, though, this would only need to happen once, as Scoop would then leave the config untouched thereafter.

My proposed change seems to work when debugging with update --force, but I'm as yet unsure of any major ramifications.

System details

Windows version: 10

OS architecture: 64bit

PowerShell version: 5.1.19041.2364, 7.3.3

Additional software: N/A

Scoop Configuration

{
  "aria2-enabled": true,
  "aria2-warning-enabled": false,
  "last_update": "2023-03-16T17:40:10.9403059+00:00",
  "scoop_branch": "master",
  "scoop_repo": "https://github.com/ScoopInstaller/Scoop",
  "use_external_7zip": true
}
@rashil2000
Copy link
Member

/cc @niheaven

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

Successfully merging a pull request may close this issue.

2 participants