Skip to content

Commit 4c5e6fd

Browse files
authored
Merge pull request #168 from erizocosmico/feature/rename-commit-has-blob
internal/function: rename commit_contains to commit_has_blob
2 parents 4272294 + 47f5701 commit 4c5e6fd

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

internal/function/commit_contains.go renamed to internal/function/commit_has_blob.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@ import (
99
"gopkg.in/src-d/go-mysql-server.v0/sql"
1010
)
1111

12-
// CommitContains is a function that checks whether a blob is in a commit.
13-
type CommitContains struct {
12+
// CommitHasBlob is a function that checks whether a blob is in a commit.
13+
type CommitHasBlob struct {
1414
commitHash sql.Expression
1515
blob sql.Expression
1616
}
1717

18-
// NewCommitContains creates a new commit_contains function.
19-
func NewCommitContains(commitHash, blob sql.Expression) sql.Expression {
20-
return &CommitContains{
18+
// NewCommitHasBlob creates a new commit_has_blob function.
19+
func NewCommitHasBlob(commitHash, blob sql.Expression) sql.Expression {
20+
return &CommitHasBlob{
2121
commitHash: commitHash,
2222
blob: blob,
2323
}
2424
}
2525

2626
// Type implements the Expression interface.
27-
func (CommitContains) Type() sql.Type {
27+
func (CommitHasBlob) Type() sql.Type {
2828
return sql.Boolean
2929
}
3030

3131
// Eval implements the Expression interface.
32-
func (f *CommitContains) Eval(session sql.Session, row sql.Row) (interface{}, error) {
32+
func (f *CommitHasBlob) Eval(session sql.Session, row sql.Row) (interface{}, error) {
3333
s, ok := session.(*gitquery.Session)
3434
if !ok {
3535
return nil, gitquery.ErrInvalidGitQuerySession.New(session)
@@ -63,14 +63,14 @@ func (f *CommitContains) Eval(session sql.Session, row sql.Row) (interface{}, er
6363
return nil, err
6464
}
6565

66-
return f.commitContains(
66+
return f.commitHasBlob(
6767
s.Pool,
6868
plumbing.NewHash(commitHash.(string)),
6969
plumbing.NewHash(blob.(string)),
7070
)
7171
}
7272

73-
func (f *CommitContains) commitContains(
73+
func (f *CommitHasBlob) commitHasBlob(
7474
pool *gitquery.RepositoryPool,
7575
commitHash, blob plumbing.Hash,
7676
) (bool, error) {
@@ -135,22 +135,22 @@ func hashInTree(hash plumbing.Hash, tree *object.Tree) (bool, error) {
135135
}
136136

137137
// Name implements the Expression interface.
138-
func (CommitContains) Name() string {
139-
return "commit_contains"
138+
func (CommitHasBlob) Name() string {
139+
return "commit_has_blob"
140140
}
141141

142142
// IsNullable implements the Expression interface.
143-
func (f CommitContains) IsNullable() bool {
143+
func (f CommitHasBlob) IsNullable() bool {
144144
return f.commitHash.IsNullable() || f.blob.IsNullable()
145145
}
146146

147147
// Resolved implements the Expression interface.
148-
func (f CommitContains) Resolved() bool {
148+
func (f CommitHasBlob) Resolved() bool {
149149
return f.commitHash.Resolved() && f.blob.Resolved()
150150
}
151151

152152
// TransformUp implements the Expression interface.
153-
func (f CommitContains) TransformUp(fn func(sql.Expression) (sql.Expression, error)) (sql.Expression, error) {
153+
func (f CommitHasBlob) TransformUp(fn func(sql.Expression) (sql.Expression, error)) (sql.Expression, error) {
154154
commitHash, err := f.commitHash.TransformUp(fn)
155155
if err != nil {
156156
return nil, err
@@ -161,5 +161,5 @@ func (f CommitContains) TransformUp(fn func(sql.Expression) (sql.Expression, err
161161
return nil, err
162162
}
163163

164-
return fn(NewCommitContains(commitHash, blob))
164+
return fn(NewCommitHasBlob(commitHash, blob))
165165
}

internal/function/commit_contains_test.go renamed to internal/function/commit_has_blob_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
"gopkg.in/src-d/go-mysql-server.v0/sql/expression"
1212
)
1313

14-
func TestCommitContains(t *testing.T) {
14+
func TestCommitHasBlob(t *testing.T) {
1515
require.NoError(t, fixtures.Init())
1616
defer func() {
1717
require.NoError(t, fixtures.Clean())
1818
}()
1919

20-
f := NewCommitContains(
20+
f := NewCommitHasBlob(
2121
expression.NewGetField(0, sql.Text, "commit_hash", true),
2222
expression.NewGetField(1, sql.Text, "blob", true),
2323
)

internal/function/registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "gopkg.in/src-d/go-mysql-server.v0/sql"
55
var functions = map[string]sql.Function{
66
"is_tag": sql.Function1(NewIsTag),
77
"is_remote": sql.Function1(NewIsRemote),
8-
"commit_contains": sql.Function2(NewCommitContains),
8+
"commit_has_blob": sql.Function2(NewCommitHasBlob),
99
"history_idx": sql.Function2(NewHistoryIdx),
1010
}
1111

0 commit comments

Comments
 (0)