Skip to content

Commit 6568a22

Browse files
authored
Merge branch 'master' into doc-724
2 parents 27c9949 + 0a56208 commit 6568a22

File tree

98 files changed

+5276
-1191
lines changed

Some content is hidden

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

98 files changed

+5276
-1191
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ addons:
1111
packages:
1212
- gcc-6
1313
- g++-6
14+
- libonig-dev
15+
1416

1517
before_install:
1618
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 90
@@ -36,8 +38,7 @@ jobs:
3638
services: [docker]
3739

3840
before_deploy:
39-
- make packages
40-
- echo "${TRAVIS_TAG}" > version.txt
41+
- make static-package
4142
- make docker-push-latest-release
4243

4344
deploy:
@@ -61,6 +62,7 @@ jobs:
6162

6263
script:
6364
- brew update
65+
- brew install oniguruma
6466
- make packages || echo "" # will fail because of docker being missing
6567
- if [ ! -f "build/gitbase_darwin_amd64/gitbase" ]; then echo "gitbase binary not generated" && exit 1; fi
6668
- cd build

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ FROM golang:1.11-alpine as builder
66
ENV GITBASE_REPO=github.com/src-d/gitbase
77
ENV GITBASE_PATH=$GOPATH/src/$GITBASE_REPO
88

9-
RUN apk add --no-cache git
9+
RUN apk add --update --no-cache libxml2-dev git make bash gcc g++ curl oniguruma-dev oniguruma
1010

1111
COPY . $GITBASE_PATH
1212
WORKDIR $GITBASE_PATH
13-
RUN go build -ldflags="-X main.version=$(cat version.txt || echo "undefined") -X main.build=$(date +"%m-%d-%Y_%H_%M_%S") -X main.commit=$(git rev-parse --short HEAD) -s -w" -o /bin/gitbase ./cmd/gitbase
13+
14+
ENV GO_BUILD_ARGS="-o /bin/gitbase"
15+
ENV GO_BUILD_PATH="./cmd/gitbase"
16+
RUN make static-build
1417

1518
#=================================
1619
# Stage 2: Start Gitbase Server

Gopkg.lock

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

Gopkg.toml

Lines changed: 2 additions & 2 deletions
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 = "v0.5.1"
3+
revision = "b32d2fdea095e2743d13f3ab4da5ae83aef55bc7"
44

55
[[constraint]]
66
name = "github.com/jessevdk/go-flags"
@@ -50,7 +50,7 @@
5050

5151
[[constraint]]
5252
name = "gopkg.in/src-d/enry.v1"
53-
version = "1.7.1"
53+
version = "1.7.2"
5454

5555
[[constraint]]
5656
name = "gopkg.in/bblfsh/client-go.v3"

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pipeline {
77
nodeSelector 'srcd.host/type=jenkins-worker'
88
containerTemplate {
99
name 'regression-gitbase'
10-
image 'srcd/regression-gitbase:v0.2.0'
10+
image 'srcd/regression-gitbase:v0.2.1'
1111
ttyEnabled true
1212
command 'cat'
1313
}

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ static-package:
3030
docker rm gitbase-temp
3131

3232
# target used in the Dockerfile to build the static binary
33-
static-build: VERSION = $(shell git describe --exact-match --tags 2>/dev/null || dev-$(git rev-parse --short HEAD)$(test -n "`git status --porcelain`" && echo "-dirty" || true))
34-
static-build: LD_FLAGS += -linkmode external -extldflags '-static -lz'
33+
static-build: VERSION ?= $(shell git describe --exact-match --tags 2>/dev/null || "dev-$(git rev-parse --short HEAD)$(test -n "`git status --porcelain`" && echo "-dirty" || true)")
34+
static-build: LD_FLAGS += -linkmode external -extldflags '-static -lz' -s -w
3535
static-build: GO_BUILD_ARGS += -tags oniguruma
36+
static-build: GO_BUILD_PATH ?= github.com/src-d/gitbase/...
3637
static-build:
37-
go install -v $(GO_BUILD_ARGS) github.com/src-d/gitbase/...
38+
go build -ldflags="$(LD_FLAGS)" -v $(GO_BUILD_ARGS) $(GO_BUILD_PATH)
3839

3940
ci-e2e: packages
4041
go test ./e2e -gitbase-version="$(TRAVIS_TAG)" \

_testdata/not-permission/.gitkeep

Whitespace-only changes.

cmd/gitbase/command/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ func (c *Server) addMatch(match string) error {
309309
initDepth := strings.Count(root, string(os.PathSeparator))
310310
return filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
311311
if err != nil {
312+
if os.IsPermission(err) {
313+
return filepath.SkipDir
314+
}
312315
return err
313316
}
314317

cmd/gitbase/command/server_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package command
22

33
import (
4+
"os"
45
"testing"
56

67
"github.com/src-d/gitbase"
@@ -10,12 +11,22 @@ import (
1011
func TestAddMatch(t *testing.T) {
1112
require := require.New(t)
1213

14+
notPermissionDir := "../../../_testdata/not-permission/"
15+
fi, err := os.Stat(notPermissionDir)
16+
require.NoError(err)
17+
18+
require.NoError(os.Chmod(notPermissionDir, 0))
19+
defer func() {
20+
require.NoError(os.Chmod(notPermissionDir, fi.Mode()))
21+
}()
22+
1323
expected := []struct {
1424
path string
1525
err func(error, ...interface{})
1626
}{
1727
{"../../../_testdata/repositories/", require.NoError},
1828
{"../../../_testdata/repositories-link/", require.NoError},
29+
{notPermissionDir, require.NoError},
1930
{"../../../_testdata/repositories-not-exist/", require.Error},
2031
}
2132
c := &Server{pool: gitbase.NewRepositoryPool(0)}

commit_blobs.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"io"
66

7-
git "gopkg.in/src-d/go-git.v4"
87
"gopkg.in/src-d/go-git.v4/plumbing"
98
"gopkg.in/src-d/go-git.v4/plumbing/object"
109
"gopkg.in/src-d/go-mysql-server.v0/sql"
@@ -103,6 +102,7 @@ func (t *commitBlobsTable) PartitionRows(
103102
return &commitBlobsRowIter{
104103
repo: repo,
105104
commits: stringsToHashes(commits),
105+
iter: nil,
106106
index: indexValues,
107107
skipGitErrors: shouldSkipErrors(ctx),
108108
}, nil
@@ -216,16 +216,18 @@ func (i *commitBlobsRowIter) Next() (sql.Row, error) {
216216
}
217217

218218
func (i *commitBlobsRowIter) init() error {
219-
var err error
220219
if len(i.commits) > 0 {
221-
i.iter, err = NewCommitsByHashIter(i.repo, i.commits)
220+
i.iter = newCommitsByHashIter(i.repo, i.commits)
222221
} else {
223-
i.iter, err = i.repo.Log(&git.LogOptions{
224-
All: true,
225-
})
222+
iter, err := newCommitIter(i.repo, i.skipGitErrors)
223+
if err != nil {
224+
return err
225+
}
226+
227+
i.iter = iter
226228
}
227229

228-
return err
230+
return nil
229231
}
230232

231233
var commitBlobsCommitIdx = CommitBlobsSchema.IndexOf("commit_hash", CommitBlobsTableName)

0 commit comments

Comments
 (0)