mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:51:57 +00:00
sg gen buf: fix completions (#62555)
The command accepts `buf.gen.yaml` files, but the current completion provides generated Go files instead. The output is also provided in absolute-path format, which is difficult to read. This change addresses both issues, though the completion is a bit slow still. ## Test plan Before (incorrect completions):  After (✅): ```sh go build -o ./sg ./dev/sg && ./sg install -f -p=false # install globally ``` <img width="883" alt="image" src="https://github.com/sourcegraph/sourcegraph/assets/23356519/7c1831bb-bffc-4918-bee2-7ecf65386cc8"> Running `sg gen buf` against some of the suggested targets works as expected
This commit is contained in:
parent
3a1d8a2ed6
commit
a7416695cd
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/sourcegraph/sourcegraph/dev/sg/buf"
|
||||
@ -22,7 +23,15 @@ var allGenerateTargets = generateTargets{
|
||||
Help: "Re-generate protocol buffer bindings using buf",
|
||||
Runner: generateProtoRunner,
|
||||
Completer: func() (options []string) {
|
||||
options, _ = buf.CodegenFiles()
|
||||
options, _ = buf.PluginConfigurationFiles()
|
||||
// Try to convert the options into relative paths for brevity
|
||||
if cwd, err := os.Getwd(); err == nil {
|
||||
for i, o := range options {
|
||||
if rel, err := filepath.Rel(cwd, o); err == nil {
|
||||
options[i] = rel
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user