Skip to content

Commit 05406e9

Browse files
committed
Use full path as ID in repository pool
Signed-off-by: Javi Fontan <[email protected]>
1 parent 26a0c21 commit 05406e9

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

integration_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gitquery_test
22

33
import (
44
"context"
5-
"path/filepath"
65
"testing"
76

87
"github.com/src-d/gitquery"
@@ -21,7 +20,6 @@ func TestIntegration(t *testing.T) {
2120
}()
2221

2322
path := fixtures.ByTag("worktree").One().Worktree().Root()
24-
dirName := filepath.Base(path)
2523

2624
pool := gitquery.NewRepositoryPool()
2725
_, err := pool.AddGit(path)
@@ -108,9 +106,9 @@ func TestIntegration(t *testing.T) {
108106
) as t
109107
GROUP BY committer_email, month, repo_id`,
110108
[]sql.Row{
111-
{int32(6), int32(3), dirName, "[email protected]"},
112-
{int32(1), int32(4), dirName, "[email protected]"},
113-
{int32(1), int32(3), dirName, "[email protected]"},
109+
{int32(6), int32(3), path, "[email protected]"},
110+
{int32(1), int32(4), path, "[email protected]"},
111+
{int32(1), int32(3), path, "[email protected]"},
114112
},
115113
},
116114
{

repositories_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package gitquery
22

33
import (
44
"context"
5-
"path/filepath"
65
"testing"
76

87
"github.com/stretchr/testify/require"
@@ -77,8 +76,6 @@ func TestRepositoriesPushdown(t *testing.T) {
7776
session, path, cleanup := setup(t)
7877
defer cleanup()
7978

80-
dirName := filepath.Base(path)
81-
8279
table := newRepositoriesTable(session.Pool).(sql.PushdownProjectionAndFiltersTable)
8380

8481
iter, err := table.WithProjectAndFilters(session, nil, nil)
@@ -103,7 +100,7 @@ func TestRepositoriesPushdown(t *testing.T) {
103100
iter, err = table.WithProjectAndFilters(session, nil, []sql.Expression{
104101
expression.NewEquals(
105102
expression.NewGetField(0, sql.Text, "id", false),
106-
expression.NewLiteral(dirName, sql.Text),
103+
expression.NewLiteral(path, sql.Text),
107104
),
108105
})
109106
require.NoError(err)

repository_pool.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ func (p *RepositoryPool) AddGit(path string) (string, error) {
6868
return "", err
6969
}
7070

71-
id := filepath.Base(path)
72-
p.Add(id, path)
71+
p.Add(path, path)
7372

74-
return id, nil
73+
return path, nil
7574
}
7675

7776
// AddDir adds all direct subdirectories from path as repos

repository_pool_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,14 @@ func TestRepositoryPoolGit(t *testing.T) {
6969
require := require.New(t)
7070

7171
path := fixtures.Basic().ByTag("worktree").One().Worktree().Root()
72-
dirName := filepath.Base(path)
7372

7473
pool := NewRepositoryPool()
7574
id, err := pool.AddGit(path)
76-
require.Equal(dirName, id)
75+
require.Equal(path, id)
7776
require.NoError(err)
7877

7978
repo, err := pool.GetPos(0)
80-
require.Equal(dirName, repo.ID)
79+
require.Equal(path, repo.ID)
8180
require.NotNil(repo.Repo)
8281
require.NoError(err)
8382

@@ -239,7 +238,7 @@ func TestRepositoryPoolAddDir(t *testing.T) {
239238
repo, err := pool.GetPos(i)
240239
require.NoError(err)
241240
arrayID[i] = repo.ID
242-
arrayExpected[i] = strconv.Itoa(i)
241+
arrayExpected[i] = filepath.Join(tmpDir, strconv.Itoa(i))
243242

244243
iter, err := repo.Repo.CommitObjects()
245244
require.NoError(err)

0 commit comments

Comments
 (0)