Skip to content

Commit f7b7912

Browse files
committed
Remove preemptive language availability check in parse
Signed-off-by: Carlos Martín <[email protected]>
1 parent f1a2335 commit f7b7912

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232

3333
- The commands fail gracefully if an incompatible Docker installation is found, such as Docker Toolbox ([#417](https://github.com/src-d/engine/issues/417)).
3434

35+
### Known Issues
36+
37+
- [#297](https://github.com/src-d/engine/issues/297): `srcd parse` does not detect the language automatically for bash files. For this language you will need to set `--lang` manually. For example:
38+
```
39+
$ srcd parse uast file.bash --lang bash
40+
```
41+
3542
</details>
3643

3744
## [v0.12.0](https://github.com/src-d/engine/releases/tag/v0.12.0) - 2019-04-04

cmd/srcd/cmd/parse.go

+13-15
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ func (cmd *parseUASTCmd) Execute(args []string) error {
7878
}
7979

8080
lang := cmd.Lang
81-
var resp *api.ListDriversResponse
82-
8381
if lang == "" {
8482
lang, err = parseLang(ctx, c, cmd.Args.Path, b)
8583
started()
@@ -89,21 +87,10 @@ func (cmd *parseUASTCmd) Execute(args []string) error {
8987
}
9088

9189
log.Infof("detected language: %s", lang)
92-
resp, err = c.ListDrivers(ctx, &api.ListDriversRequest{})
9390
} else {
94-
resp, err = c.ListDrivers(ctx, &api.ListDriversRequest{})
9591
started()
9692
}
9793

98-
if err != nil {
99-
return humanizef(err, "could not list drivers")
100-
}
101-
102-
err = checkSupportedLanguage(resp.Drivers, lang)
103-
if err != nil {
104-
return err
105-
}
106-
10794
stream, err := c.ParseWithLogs(ctx, &api.ParseRequest{
10895
Kind: api.ParseRequest_UAST,
10996
Name: cmd.Args.Path,
@@ -123,6 +110,12 @@ func (cmd *parseUASTCmd) Execute(args []string) error {
123110
}
124111

125112
if err != nil {
113+
if strings.Contains(err.Error(), "missing driver for language") {
114+
if err := checkSupportedLanguage(ctx, c, lang); err != nil {
115+
return err
116+
}
117+
}
118+
126119
return humanizef(err, "could not stream")
127120
}
128121

@@ -211,10 +204,15 @@ func parseLang(ctx context.Context, client api.EngineClient, path string, b []by
211204
return res.Lang, nil
212205
}
213206

214-
func checkSupportedLanguage(supportedDrivers []*api.ListDriversResponse_DriverInfo, desired string) error {
207+
func checkSupportedLanguage(ctx context.Context, c api.EngineClient, desired string) error {
208+
resp, errList := c.ListDrivers(ctx, &api.ListDriversRequest{})
209+
if errList != nil {
210+
return humanizef(errList, "could not list drivers")
211+
}
212+
215213
var langs []string
216214
isSupported := false
217-
for _, driver := range supportedDrivers {
215+
for _, driver := range resp.Drivers {
218216
langs = append(langs, driver.Lang)
219217
if driver.Lang == desired {
220218
isSupported = true

0 commit comments

Comments
 (0)