Skip to content

Commit

Permalink
Fix aliases usage on bblfsh client impl. (#881)
Browse files Browse the repository at this point in the history
Fix aliases usage on bblfsh client impl.
  • Loading branch information
ajnavarro authored Jun 19, 2019
2 parents 044fcad + 49b8e34 commit 46fa72a
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 26 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ before_install:
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 90

before_script:
- docker run -d --name bblfshd --privileged -p 9432:9432 -v /var/lib/bblfshd:/var/lib/bblfshd bblfsh/bblfshd
- docker exec -it bblfshd bblfshctl driver install python bblfsh/python-driver
- docker exec -it bblfshd bblfshctl driver install php bblfsh/php-driver
- docker exec -it bblfshd bblfshctl driver install go bblfsh/go-driver
- docker run -d --name bblfshd --privileged -p 9432:9432 bblfsh/bblfshd:v2.14.0-drivers
- docker exec -it bblfshd bblfshctl driver list
- go get -v github.com/go-sql-driver/mysql/...
- go get gopkg.in/src-d/go-git-fixtures.v3/...

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.21.0-beta3] - 2019-06-19

### Fixed

- bblfsh aliases are now handled correctly ([#728](https://github.com/src-d/gitbase/issues/728)).
- sql: correctly handle nulls in SQL type conversion ([#753](https://github.com/src-d/go-mysql-server/pull/753))
- sql/parse: error for unsupported distinct on aggregations ([#869](https://github.com/src-d/gitbase/issues/869))

## [0.21.0-beta2] - 2019-06-18

### Added
Expand Down
14 changes: 13 additions & 1 deletion _testdata/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@
ID: 'query04'
Name: 'Top 10 repositories by contributor count (all branches)'
Statements:
- SELECT repository_id,contributor_count FROM (SELECT repository_id, COUNT(DISTINCT commit_author_email) AS contributor_count FROM commits GROUP BY repository_id) AS q ORDER BY contributor_count DESC LIMIT 10
- >
SELECT
repository_id,
COUNT(commit_author_email) as contributor_count
FROM (
SELECT DISTINCT
repository_id,
commit_author_email
FROM commits
) as q
GROUP BY repository_id
ORDER BY contributor_count DESC
LIMIT 10
-
ID: 'query05'
Name: 'Query all files from HEAD'
Expand Down
2 changes: 1 addition & 1 deletion docs/using-gitbase/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

`gitbase` optional dependencies that should be running on your system if you're planning on using certain functionality.

- [bblfsh](https://github.com/bblfsh/bblfshd) >= 2.10.0 (only if you're planning to use the `UAST` functionality provided in gitbase)
- [bblfsh](https://github.com/bblfsh/bblfshd) >= 2.14.0 (only if you're planning to use the `UAST` functionality provided in gitbase)

## Installing gitbase

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/src-d/enry/v2 v2.0.0
github.com/src-d/go-git v4.7.0+incompatible
github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible
github.com/src-d/go-mysql-server v0.4.1-0.20190617130801-5f48ea31ce99
github.com/src-d/go-mysql-server v0.4.1-0.20190619104848-eaab1795353a
github.com/stretchr/testify v1.3.0
github.com/uber-go/atomic v1.4.0 // indirect
github.com/uber/jaeger-client-go v2.16.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ github.com/src-d/go-git v4.7.0+incompatible h1:IYSSnbAHeKmsfbQFi9ozbid+KNh0bKjlo
github.com/src-d/go-git v4.7.0+incompatible/go.mod h1:1bQciz+hn0jzPQNsYj0hDFZHLJBdV7gXE2mWhC7EkFk=
github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible h1:A5bKevhs9C//Nh8QV0J+1KphEaIa25cDe1DTs/yPxDI=
github.com/src-d/go-git-fixtures v3.5.1-0.20190605154830-57f3972b0248+incompatible/go.mod h1:XcIQp7L+k0pgfTqfbaTKj3kxlBv8kYOKZ/tKNXbZFLg=
github.com/src-d/go-mysql-server v0.4.1-0.20190617130801-5f48ea31ce99 h1:oZMn2HmQlDRHxWvyXRZnE9uUwUaVXVE/qrcvuFFDJ7s=
github.com/src-d/go-mysql-server v0.4.1-0.20190617130801-5f48ea31ce99/go.mod h1:GO8SmBnN9LcKSXy6DYuBbqKtJvrRnHsBrlXvlVOX+NM=
github.com/src-d/go-mysql-server v0.4.1-0.20190619104848-eaab1795353a h1:tAgjKO6ynjJasm6wTSjmFJIf/lh/Rk3dPVCUnOXAWEQ=
github.com/src-d/go-mysql-server v0.4.1-0.20190619104848-eaab1795353a/go.mod h1:GO8SmBnN9LcKSXy6DYuBbqKtJvrRnHsBrlXvlVOX+NM=
github.com/src-d/go-oniguruma v1.0.0 h1:JDk5PUAjreGsGAKLsoDLNmrsaryjJ5RqT3h+Si6aw/E=
github.com/src-d/go-oniguruma v1.0.0/go.mod h1:chVbff8kcVtmrhxtZ3yBVLLquXbzCS6DrxQaAK/CeqM=
github.com/src-d/go-oniguruma v1.1.0 h1:EG+Nm5n2JqWUaCjtM0NtutPxU7ZN5Tp50GWrrV8bTww=
Expand Down
31 changes: 15 additions & 16 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (

"github.com/src-d/gitbase"
"github.com/src-d/gitbase/internal/function"
"github.com/stretchr/testify/require"
fixtures "github.com/src-d/go-git-fixtures"
"gopkg.in/src-d/go-git.v4/plumbing/cache"
sqle "github.com/src-d/go-mysql-server"
"github.com/src-d/go-mysql-server/auth"
"github.com/src-d/go-mysql-server/sql"
"github.com/src-d/go-mysql-server/sql/analyzer"
"github.com/src-d/go-mysql-server/sql/index/pilosa"
"github.com/stretchr/testify/require"
"gopkg.in/src-d/go-git.v4/plumbing/cache"
)

func TestIntegration(t *testing.T) {
Expand Down Expand Up @@ -330,20 +330,20 @@ func TestIntegration(t *testing.T) {
},
{
`
SELECT
repository_id,
contributor_count
FROM (
SELECT
repository_id,
COUNT(DISTINCT commit_author_email) AS contributor_count
FROM commits
GROUP BY repository_id
) AS q
ORDER BY contributor_count DESC
LIMIT 10
SELECT
repository_id,
COUNT(commit_author_email) as contributor_count
FROM (
SELECT DISTINCT
repository_id,
commit_author_email
FROM commits
) as q
GROUP BY repository_id
ORDER BY contributor_count DESC
LIMIT 10
`,
[]sql.Row{{"worktree", int64(9)}},
[]sql.Row{{"worktree", int64(2)}},
},
{
`SELECT cf.file_path
Expand Down Expand Up @@ -394,7 +394,6 @@ func TestIntegration(t *testing.T) {
require.NoError(err)
rows, err := sql.RowIterToRows(iter)
require.NoError(err)

require.ElementsMatch(tt.result, rows)
})
}
Expand Down
3 changes: 2 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (c *BblfshClient) IsLanguageSupported(ctx context.Context, lang string) (bo
}

for _, lng := range langs {
if lng == strings.ToLower(lang) {
if strings.ToLower(lng) == strings.ToLower(lang) {
return true, nil
}
}
Expand All @@ -126,6 +126,7 @@ func (c *BblfshClient) SupportedLanguages(ctx context.Context) ([]string, error)

for _, dm := range driverManifests {
c.supportedLanguages = append(c.supportedLanguages, dm.Language)
c.supportedLanguages = append(c.supportedLanguages, dm.Aliases...)
}
}

Expand Down
14 changes: 14 additions & 0 deletions session_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gitbase

import (
"context"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -17,6 +18,19 @@ func TestSessionBblfshClient(t *testing.T) {
require.Equal(connectivity.Ready, cli.GetState())
}

func TestSupportedLanguagesAliases(t *testing.T) {
require := require.New(t)

session := NewSession(nil, WithBblfshEndpoint(defaultBblfshEndpoint))
cli, err := session.BblfshClient()
require.NoError(err)
require.NotNil(cli)
require.Equal(connectivity.Ready, cli.GetState())
ok, err := cli.IsLanguageSupported(context.TODO(), "C++")
require.NoError(err)
require.True(ok)
}

func TestSessionBblfshClientNoConnection(t *testing.T) {
require := require.New(t)

Expand Down

0 comments on commit 46fa72a

Please sign in to comment.