sg: ensure src-cli runs w/ client-only during setup (#46492)

Previously, src-cli version was ran without the --client-only flag,
which triggered an external request. In some cases, users have their
SRC_* env vars already set and pointing at their local instance, which
will fail the check if the instance is not running already.

This is now corrected and the check will pass, because it only looks at
the client version.

Test Plan: locally tested.
This commit is contained in:
Jean-Hadrien Chabran 2023-01-16 12:09:34 +01:00 committed by GitHub
parent 0ca10ac62c
commit d4943115d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -245,12 +245,12 @@ func checkGitVersion(versionConstraint string) func(context.Context) error {
func checkSrcCliVersion(versionConstraint string) func(context.Context) error {
return func(ctx context.Context) error {
lines, err := usershell.Command(ctx, "src version").StdOut().Run().Lines()
lines, err := usershell.Command(ctx, "src version -client-only").StdOut().Run().Lines()
if err != nil {
return errors.Wrapf(err, "failed to run 'src version'")
}
if len(lines) < 2 {
if len(lines) < 1 {
return errors.Newf("unexpected output from src: %s", strings.Join(lines, "\n"))
}
out := lines[0]

View File

@ -133,7 +133,7 @@ var Mac = []category{
// src-cli is installed differently on Ubuntu and Mac
&dependency{
Name: "src",
Check: checkAction(check.Combine(check.InPath("src"), checkSrcCliVersion(">= 4.0.2"))),
Check: checkAction(check.Combine(check.InPath("src"), checkSrcCliVersion(">= 4.2.0"))),
Fix: cmdFix(`brew upgrade sourcegraph/src-cli/src-cli || brew install sourcegraph/src-cli/src-cli`),
},
),