GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — test: add unit tests for version-check comparison and skip logic by Montana · Pull Request #1339 · sourcegraph/src-cli Conversation
|
|
Hi @burmudar, You're right. I'd added the comparison and skip helpers but never invoked them, so the check was dead code. Fixed by calling Behavior matches the PR description: fail-open on any error, 3s timeout, stderr only so One thing to flag, because this runs before flag parsing, I've reopened another 2 PR's that should address this, you can fold them together if you want. Cheers, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Before running a command, src does a best-effort check of the running version against the version recommended by the configured instance (/.api/src-cli/version) and prints a single stderr warning when behind. Fail-open, 3s timeout, stderr only so --json is unaffected. Skips version/help/no-arg, dev builds, and SRC_SKIP_VERSION_CHECK. Compares major/minor/patch only. Adds unit tests. Closes sourcegraph#930. Supersedes sourcegraph#1339, sourcegraph#1343.
…ion (#1403) * feat: warn when src-cli is older than the instance's recommended version Before running a command, src does a best-effort check of the running version against the version recommended by the configured instance (/.api/src-cli/version) and prints a single stderr warning when behind. Fail-open, 3s timeout, stderr only so --json is unaffected. Skips version/help/no-arg, dev builds, and SRC_SKIP_VERSION_CHECK. Compares major/minor/patch only. Adds unit tests. Closes #930. Supersedes #1339, #1343. * fix: make the outdated-version warning safe to ship - Fix a nil pointer panic on every command in release builds: the check built its API client from a zero-value api.Flags. - Run the check after flags and config are resolved, so -endpoint and -config are honored and the right instance is asked. - Ask the instance at most once every 24 hours per endpoint, caching the answer, including a failed lookup, under the user cache directory, so an instance that does not answer cannot delay every command. - Compare versions with Masterminds/semver, which is already linked into the binary, instead of a hand-written parser. - Skip 'src version' by its parsed subcommand instead of scanning every argument for the word. - Test the check end to end against a fake instance. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c29c-9f51-7761-a4ba-4d4f46dcd4ef Co-authored-by: Amp <[email protected]> * fix: run the version check with the command's own API client The check ran before the subcommand's flags were parsed, so it ignored -insecure-skip-verify and never warned on instances with an untrusted certificate. It also ran twice for nested legacy commands such as 'src repos list', which printed the warning twice. Run it once per process from config.apiClient instead, using the client the command asked for. Commands that never talk to the instance, such as 'src search -h', no longer trigger a lookup. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c29c-9f51-7761-a4ba-4d4f46dcd4ef Co-authored-by: Amp <[email protected]> * docs: document the outdated-version warning and SRC_SKIP_VERSION_CHECK * feat: make 'src version' warn too, and refresh the cached version 'src version' was the one command that never warned. It now prints the warning from the answer it just got from the instance, and caches that answer, so the commands that follow warn about the same version. It still makes a single request, and 'src version -client-only' still makes none: the check that other commands get from config.apiClient keeps skipping 'src version'. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c29c-9f51-7761-a4ba-4d4f46dcd4ef Co-authored-by: Amp <[email protected]> * docs: remove the README section on the version check The warning already names SRC_SKIP_VERSION_CHECK and links to the upgrade instructions, and CHANGELOG.md describes the feature. This reverts commit 71363c8. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c29c-9f51-7761-a4ba-4d4f46dcd4ef Co-authored-by: Amp <[email protected]> --------- Co-authored-by: Montana <[email protected]> Co-authored-by: Amp <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.