feat: warn when src-cli is older than the instance's recommended version#1347
Open
Montana wants to merge 1 commit into
Open
feat: warn when src-cli is older than the instance's recommended version#1347Montana wants to merge 1 commit into
Montana wants to merge 1 commit into
Conversation
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.
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.
Hey @burmudar,
This is superseded by my last PR. I've consolidated the implementation, the
main()wiring, and these tests into a single PR that builds. Splitting the tests out on their own was my mistake; on its own that branch didn't compile. I've run thegochecks locally (build and tests on 1.26.4) and they pass without error.What's in it:
main()viamaybeWarnVersion, and reuses the existinggetRecommendedVersionhelper against/.api/src-cli/versionrather than duplicating the request.--jsonoutput is unaffected.version,help, and no-arg invocations, dev builds (version.BuildTag == version.DefaultBuildTag), and any run withSRC_SKIP_VERSION_CHECKset.parseVersion,isOlderVersion, andskipVersionCheck, including the prerelease and fail-open cases and each skip path.One design note worth flagging: the check runs before flag parsing, so
-endpointand-configpassed as flags aren't picked up by the early config read. The endpoint resolves fromSRC_ENDPOINT, the config file, or the default. I kept it there to preserve the fail-open behavior, but happy to move the call after config resolution if you'd rather flags be honored.I'll close #1339 and #1343 as superseded. PTAL when you have a chance.
Cheers,
Michael