Skip to content

Commit e6ad89b

Browse files
authored
Merge pull request #224 from erizocosmico/feature/siva
gitbase: add support for siva files
2 parents 16f7f4f + fb4f97c commit e6ad89b

Some content is hidden

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

63 files changed

+4072
-51
lines changed

Gopkg.lock

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.

_testdata/not-siva.txt

Whitespace-only changes.

cmd/gitbase/server.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ var enableUnstableSquash = os.Getenv("UNSTABLE_SQUASH_ENABLE") != ""
2424
type cmdServer struct {
2525
Verbose bool `short:"v" description:"Activates the verbose mode"`
2626

27-
Git string `short:"g" long:"git" description:"Path where the git repositories are located, one per dir"`
27+
Git string `short:"g" long:"git" description:"Path where the git repositories are located"`
28+
Siva string `long:"siva" description:"Path where the siva repositories are located"`
2829
Host string `short:"h" long:"host" default:"localhost" description:"Host where the server is going to listen"`
2930
Port int `short:"p" long:"port" default:"3306" description:"Port where the server is going to listen"`
3031
User string `short:"u" long:"user" default:"root" description:"User name used for connection"`
@@ -44,12 +45,12 @@ func (c *cmdServer) buildDatabase() error {
4445
logrus.WithField("dir", c.Git).Debug("added folder containing git repositories")
4546
}
4647

47-
var err error
48+
c.pool = gitbase.NewRepositoryPool()
49+
if err := c.pool.AddDir(c.Git); err != nil {
50+
return err
51+
}
4852

49-
pool := gitbase.NewRepositoryPool()
50-
c.pool = &pool
51-
err = c.pool.AddDir(c.Git)
52-
if err != nil {
53+
if err := c.pool.AddSivaDir(c.Siva); err != nil {
5354
return err
5455
}
5556

common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func setup(t *testing.T) (ctx *sql.Context, path string, cleanup CleanupFunc) {
3030
require.NoError(fixtures.Clean())
3131
}
3232

33-
session := NewSession(&pool)
33+
session := NewSession(pool)
3434
ctx = sql.NewContext(context.TODO(), sql.WithSession(session))
3535

3636
return ctx, path, cleanup

integration_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func TestIntegration(t *testing.T) {
139139
t.Run(tt.query, func(t *testing.T) {
140140
require := require.New(t)
141141

142-
session := gitbase.NewSession(&pool)
142+
session := gitbase.NewSession(pool)
143143
ctx := sql.NewContext(context.TODO(), sql.WithSession(session))
144144

145145
_, iter, err := engine.Query(ctx, tt.query)
@@ -173,7 +173,7 @@ func TestUastQueries(t *testing.T) {
173173
engine.AddDatabase(gitbase.NewDatabase("foo"))
174174
engine.Catalog.RegisterFunctions(function.Functions)
175175

176-
session := gitbase.NewSession(&pool)
176+
session := gitbase.NewSession(pool)
177177
ctx := sql.NewContext(context.TODO(), sql.WithSession(session))
178178
_, iter, err := engine.Query(ctx, `
179179
SELECT uast_xpath(uast(content, 'php'), '//*[@roleIdentifier]') as uast, name
@@ -249,8 +249,8 @@ func TestSquashCorrectness(t *testing.T) {
249249

250250
for _, q := range queries {
251251
t.Run(q, func(t *testing.T) {
252-
expected := queryResults(t, engine, &pool, q)
253-
result := queryResults(t, squashEngine, &pool, q)
252+
expected := queryResults(t, engine, pool, q)
253+
result := queryResults(t, squashEngine, pool, q)
254254
require.ElementsMatch(
255255
t,
256256
expected,
@@ -374,7 +374,7 @@ func benchmarkQuery(b *testing.B, query string) {
374374
pool := gitbase.NewRepositoryPool()
375375
_, err := pool.AddGit(path)
376376
require.NoError(b, err)
377-
session := gitbase.NewSession(&pool)
377+
session := gitbase.NewSession(pool)
378378
ctx := sql.NewContext(context.TODO(), sql.WithSession(session))
379379

380380
run := func(b *testing.B) {

internal/function/commit_has_blob_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestCommitHasBlob(t *testing.T) {
2727
pool.AddGit(f.Worktree().Root())
2828
}
2929

30-
session := gitbase.NewSession(&pool)
30+
session := gitbase.NewSession(pool)
3131
ctx := sql.NewContext(context.TODO(), sql.WithSession(session))
3232

3333
testCases := []struct {
@@ -72,7 +72,7 @@ func BenchmarkCommitHasBlob(b *testing.B) {
7272
pool.AddGit(f.Worktree().Root())
7373
}
7474

75-
session := gitbase.NewSession(&pool)
75+
session := gitbase.NewSession(pool)
7676
ctx := sql.NewContext(context.TODO(), sql.WithSession(session))
7777

7878
rows := []sql.Row{

internal/function/commit_has_tree_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestCommitHasTree(t *testing.T) {
2727
pool.AddGit(f.Worktree().Root())
2828
}
2929

30-
session := gitbase.NewSession(&pool)
30+
session := gitbase.NewSession(pool)
3131
ctx := sql.NewContext(context.TODO(), sql.WithSession(session))
3232

3333
testCases := []struct {
@@ -73,7 +73,7 @@ func BenchmarkCommitHasTree(b *testing.B) {
7373
pool.AddGit(f.Worktree().Root())
7474
}
7575

76-
session := gitbase.NewSession(&pool)
76+
session := gitbase.NewSession(pool)
7777
ctx := sql.NewContext(context.TODO(), sql.WithSession(session))
7878

7979
rows := []sql.Row{

0 commit comments

Comments
 (0)