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

Add replace for regexp, allow regexp and replace for jsonpaths #1709

Merged
merged 3 commits into from
Sep 28, 2017
Merged

Add replace for regexp, allow regexp and replace for jsonpaths #1709

merged 3 commits into from
Sep 28, 2017

Conversation

se35710
Copy link
Contributor

@se35710 se35710 commented Sep 15, 2017

Allows for more dynamic version extractions, eg when jsonpath doesn't exactly match the version, or when you want to rearrange the regexp matches for a better version string.

I've changed so now both jp and re are allowed at the same time. jp is executed first, and then re is applied on the jsonpath. If replace is defined, it is applied on the regexp match.

Examples:

    "checkver": {
        "url": "https://superduper.io/versions.json",
        "jp": "$..name",
        "re": "(?<version>[\\d.]+)",
        "replace": "2.${version}"
    },

@r15ch13
Copy link
Member

r15ch13 commented Sep 15, 2017

Cool 👍
Do you have an example of the replace thing? Does it result in 2.1.0 if the regex matched 1.0?

superduper.io 😁

@se35710
Copy link
Contributor Author

se35710 commented Sep 15, 2017

Yes, and it works with mutiple matching groups too, so "${1}-${date}" would create a version string of "0.0.1-19620102".

The example above was with jsonpath, but this would work too.

    "checkver": {
        "url": "https://superduper.io/versions.html",
        "re": "(?<date>[\\d]+)\\sdupes-([\\d.]+)",
        "replace": "${1}-${date}"
    },

@r15ch13
Copy link
Member

r15ch13 commented Sep 15, 2017

When checkver is only a string (see 7zip, wget) then $replace would be the replace() function from System.String. 😁

@r15ch13
Copy link
Member

r15ch13 commented Sep 15, 2017

@nightroman does this work fine on your end?

@nightroman
Copy link
Contributor

@nightroman does this work fine on your end?

It sounds good and I have use cases for this feature. I am on holiday, will try only in a week or two.

@nightroman
Copy link
Contributor

It seems to be working for me with a manifest like

{
    "url":  "https://download.sysinternals.com/files/SysinternalsSuite.zip",
    "version":  "June.14.2017",
    "env_set":  {
                    "SysinternalsSuite":  "$dir"
                },
    "homepage":  "https://technet.microsoft.com/en-us/sysinternals/bb842062.aspx",
    "checkver":  {
                     "re":  "\\bUpdated:\\s*(\\w+)\\s+(\\d+),\\s+(\\d+)\\b",
                     "replace":  "${1}.${2}.${3}"
                 }
}

@r15ch13 r15ch13 merged commit 42ed53b into ScoopInstaller:master Sep 28, 2017
r15ch13 added a commit that referenced this pull request Sep 28, 2017
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.

3 participants