Skip to content

Commit c2a57b7

Browse files
authored
Merge branch 'master' into fix/squash-unsquashable
2 parents 16a22e1 + 568a476 commit c2a57b7

File tree

1,157 files changed

+249886
-15195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,157 files changed

+249886
-15195
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ jobs:
3838

3939
before_deploy:
4040
- make packages
41-
42-
after_deploy:
43-
- DOCKER_PUSH_LATEST=1 make docker-push
41+
- export DOCKER_PUSH_LATEST=$(echo ${TRAVIS_BRANCH} | grep -E '^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$') || true
42+
- make docker-push
43+
- make static-package
4444

4545
deploy:
4646
provider: releases

Dockerfile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
FROM golang:1.10 as builder
1+
FROM golang:1.11-alpine as builder
22

33
RUN mkdir -p /go/src/github.com/src-d/gitbase
44
WORKDIR /go/src/github.com/src-d/gitbase
55
COPY . .
66

7-
RUN apt-get update && apt-get install libxml2-dev -y
7+
RUN apk add --update libxml2-dev git make bash gcc g++ curl oniguruma-dev
88
RUN go get github.com/golang/dep/...
99
RUN dep ensure
1010
RUN cd vendor/gopkg.in/bblfsh/client-go.v2 && make dependencies
11-
RUN go install -v github.com/src-d/gitbase/...
11+
RUN go install -v -tags oniguruma -ldflags "-linkmode external -extldflags '-static -lz'" github.com/src-d/gitbase/...
1212

13-
FROM ubuntu:16.04
13+
FROM alpine:3.8
1414

1515
COPY --from=builder /go/bin/gitbase /bin
1616
RUN mkdir -p /opt/repos
@@ -21,14 +21,9 @@ ENV GITBASE_REPOS=/opt/repos
2121
EXPOSE 3306
2222

2323
ENV TINI_VERSION v0.17.0
24-
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
24+
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
2525
RUN chmod +x /tini
2626

27-
RUN apt-get update \
28-
&& apt-get install libxml2-dev git -y \
29-
&& apt-get clean \
30-
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
31-
3227
ENTRYPOINT ["/tini", "--"]
3328

3429
CMD gitbase server -v \

Gopkg.lock

Lines changed: 21 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[constraint]]
22
name = "gopkg.in/src-d/go-mysql-server.v0"
3-
revision = "95285948912f7edaf92e2e66e44fa6c6ad509942"
3+
revision = "1fa8e98aab8f06ae1569c4d381ccc9d3051f761a"
44

55
[[constraint]]
66
name = "github.com/jessevdk/go-flags"

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,13 @@ dependencies: bblfsh-client
2424

2525
upgrade:
2626
go run tools/rev-upgrade/main.go -p $(UPGRADE_PRJ) -r $(UPGRADE_REV)
27+
28+
static-package:
29+
PACKAGE_NAME=gitbase_$(VERSION)_static_linux_amd64 ; \
30+
docker rm gitbase-temp ; \
31+
docker create --rm --name gitbase-temp $(DOCKER_ORG)/gitbase:$(VERSION) && \
32+
mkdir -p build/$${PACKAGE_NAME} && \
33+
docker cp gitbase-temp:/bin/gitbase build/$${PACKAGE_NAME} && \
34+
cd build && \
35+
tar czvf $${PACKAGE_NAME}.tar.gz $${PACKAGE_NAME} && \
36+
docker rm gitbase-temp

cmd/gitbase/command/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"gopkg.in/src-d/go-mysql-server.v0/sql"
2222
"gopkg.in/src-d/go-mysql-server.v0/sql/analyzer"
2323
"gopkg.in/src-d/go-mysql-server.v0/sql/index/pilosa"
24-
"gopkg.in/src-d/go-vitess.v0/mysql"
24+
"gopkg.in/src-d/go-vitess.v1/mysql"
2525
)
2626

2727
const (

docs/using-gitbase/configuration.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
| `GITBASE_INDEX_DIR` | directory to save indexes, default `/var/lib/gitbase/index` |
1212
| `GITBASE_TRACE` | enable jaeger tracing, default disabled |
1313
| `GITBASE_READONLY` | allow read queries only, disabling creating and deleting indexes, default disabled |
14-
| `GITBASE_LANGUAGE_CACHE_SIZE` | size of the cache for the `language` UDF. The size is the maximum number of elements kept in the cache, 10000 by default |
15-
| `GITBASE_UAST_CACHE_SIZE` | size of the cache for the `uast` and `uast_mode` UDFs. The size is the maximum number of elements kept in the cache, 10000 by default |
14+
| `GITBASE_LANGUAGE_CACHE_SIZE`| size of the cache for the `language` UDF. The size is the maximum number of elements kept in the cache, 10000 by default |
15+
| `GITBASE_UAST_CACHE_SIZE` | size of the cache for the `uast` and `uast_mode` UDFs. The size is the maximum number of elements kept in the cache, 10000 by default |
16+
| `GITBASE_CACHESIZE_MB` | size of the cache for git objects specified as MB |
1617

1718
### Jaeger tracing variables
1819

@@ -73,6 +74,8 @@ Help Options:
7374
-u, --user= User name used for connection (default: root)
7475
-P, --password= Password used for connection
7576
-i, --index= Directory where the gitbase indexes information will be persisted. (default: /var/lib/gitbase/index) [$GITBASE_INDEX_DIR]
77+
--cache= Object cache size in megabytes (default: 512) [$GITBASE_CACHESIZE_MB]
78+
--parallelism= Maximum number of parallel threads per table. By default, it's the number of CPU cores. 0 means default, 1 means disabled.
7679
--no-squash Disables the table squashing.
7780
--trace Enables jaeger tracing [$GITBASE_TRACE]
7881
-r, --readonly Only allow read queries. This disables creating and deleting indexes as well. [$GITBASE_READONLY]

docs/using-gitbase/functions.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ To make some common tasks easier for the user, there are some functions to inter
1515
|uast_extract(blob, key)| extracts information identified by the given key from the uast nodes |
1616
|uast_children(blob)| returns a flattened array of the children UAST nodes from each one of the UAST nodes in the given sequence |
1717

18+
19+
## Note about uast and uast_mode functions
20+
21+
The data returned by these functions are a list of UAST nodes serialized as explained below.
22+
23+
Each node is serialized sequentially using [protobuf](https://developers.google.com/protocol-buffers/) and prefixed by an Int32 (in big endian byte order) specifying the length of the serialized node. The [bblfsh/sdk](https://github.com/bblfsh/sdk) contains the proto files and the tools to do it.
24+
25+
It results in a byte stream following this structure:
26+
```
27+
BigEndianInt32(len(marhsal(node))+marshal(node)+
28+
BigEndianInt32(len(marhsal(node))+marshal(node)+
29+
BigEndianInt32(len(marhsal(node))+marshal(node)+
30+
...
31+
```
32+
1833
## Standard functions
1934

20-
You can check standard functions in [`go-mysql-server` documentation](https://github.com/src-d/go-mysql-server/tree/95285948912f7edaf92e2e66e44fa6c6ad509942#custom-functions).
35+
You can check standard functions in [`go-mysql-server` documentation](https://github.com/src-d/go-mysql-server/tree/1fa8e98aab8f06ae1569c4d381ccc9d3051f761a#custom-functions).

docs/using-gitbase/getting-started.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ go get -u github.com/src-d/gitbase/...
4343

4444
#### Oniguruma support
4545

46+
**Note:** Oniguruma is enabled in the docker container and "static" linux binary.
47+
4648
On linux and macOS you can choose to build gitbase with oniguruma support, resulting in faster results for queries using the `language` UDF.
4749

4850
macOS:

docs/using-gitbase/indexes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ Note that you can create an index either **on one or more columns** or **on a si
1010

1111
You can find some more examples in the [examples](./examples.md#create-an-index-for-columns-on-a-table) section.
1212

13-
See [go-mysql-server](https://github.com/src-d/go-mysql-server/tree/95285948912f7edaf92e2e66e44fa6c6ad509942#indexes) documentation for more details
13+
See [go-mysql-server](https://github.com/src-d/go-mysql-server/tree/1fa8e98aab8f06ae1569c4d381ccc9d3051f761a#indexes) documentation for more details

0 commit comments

Comments
 (0)