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] Function Update-ManifestProperty rewrites fields in autoupdate if it is a PSCustomObject #5933

Closed
amorphobia opened this issue May 1, 2024 · 1 comment · Fixed by #5964
Labels

Comments

@amorphobia
Copy link
Contributor

Bug Report

Current Behavior

I'll use a sample manifest to illustrate the issue. I have modified sudo.json in main bucket as following:

{
    "version": "0.1", # modified
    "description": "An approximation of the Unix sudo command. Shows a UAC popup window unfortunately.",
    "homepage": "https://github.com/lukesampson/psutils",
    "license": "MIT",
    "url": "https://raw.githubusercontent.com/lukesampson/psutils/c7116ac143ca81f223e6091d0974f45ac241eb1d/sudo.ps1",
    "hash": "0d3cf564dc584ea98b213b4763228dee523c32388b1293e77eff70344d294aa8",
    "bin": "sudo.ps1",
    "env_set": {
        "SUDO_VERSION": "0.1" # added
    },
    "checkver": {
        "url": "https://github.com/lukesampson/psutils/commits/master/sudo.ps1.atom",
        "regex": "(?s)>(\\d+)-(\\d+)-(\\d+)T.*?/(?<sha>[0-9a-f]{40})",
        "replace": "0.${1}.${2}.${3}"
    },
    "autoupdate": {
        "url": "https://raw.githubusercontent.com/lukesampson/psutils/$matchSha/sudo.ps1",
        "env_set": {
            "SUDO_VERSION": "$version" # added
        }
    }
}

I have add env_set and autoupdate.env_set, as well as change the current version to 0.1. Then run

& "$env:SCOOP_HOME/bin/checkver.ps1" -Dir <bucket_dir> -Update sudo

As a result, SUDO_VERSION in both env_set and autoupdate.env_set were changed to 0.2020.01.26.

Expected Behavior

Only SUDO_VERSION under env_set will be updated, and the value under autoupdate.env_set should keep the substitution pattern.

Possible Solution

The assignment operation for PSCustomObject only passes by reference, a copy operation can fix it.

System details

Windows version: 10

OS architecture: 64bit

PowerShell version: 5.1.20348.2400

@amorphobia amorphobia added the bug label May 1, 2024
@amorphobia
Copy link
Contributor Author

I will commit a change trying to fix it.

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.

1 participant