Repository navigation
feat: add a best-effort semver() function to filter expressions - #2
Open
keegancsmith wants to merge 1 commit into
Open
keegancsmith wants to merge 1 commit into
keegancsmith wants to merge 1 commit into
Conversation
Workiva asked for version comparisons, such as finding dependencies older than a version or whether a declared range accepts one, which regexes can't express. Version strings in package.json files, lockfiles and workflows are rarely strict semver, so semver(value, range) parses them loosely (v4, 18.x, ^1.2, actions/checkout@v4, pnpm@9+sha512...) and treats anything it can't read as false rather than an error. Both arguments are parsed as ranges and the function asks whether they overlap. That covers version-in-range, range-accepts-version, and, with !, "can't resolve below X", with one function. Amp-Thread-ID: https://ampcode.com/threads/T-01a21660-38a0-70c9-b11d-fd07df914a14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Workiva asked for semver-aware comparisons in Sourcegraph's
jsonpath:filter (Linear CU-4085). Versions in config files are rarely strict semver, sosemver(value, range)parses loosely (v4,18.x,^1.2,actions/checkout@v4,pnpm@9.15.0+sha512..., pnpm lockfile peer suffixes) and treats values it can't read as false. Both arguments are parsed as npm-style ranges and the function is true when they overlap, so one function covers "version below X", "range accepts X" (Workiva'saccepts(18.3.1)), and with!, "can't resolve below X". The SOURCEGRAPH.md entry has the full semantics.Please merge with a merge commit (not squash) so the commit Sourcegraph's go.mod pins stays on
main.