Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudson Oliveira committed Dec 28, 2016
1 parent f6b7032 commit 9242a1a
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 100 deletions.
2 changes: 1 addition & 1 deletion cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func runQuery(query, folder, typeFormat string) error {
return err
}

return runtime.Run(ast, &typeFormat);
return runtime.Run(ast, &typeFormat)
}

func (cmd *Gitql) parseCommandLine() error {
Expand Down
22 changes: 11 additions & 11 deletions lexical/lexemes.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package lexical

const L_SELECT = "select";
const L_FROM = "from";
const L_WHERE = "where";
const L_ORDER = "order";
const L_BY = "by";
const L_OR = "or";
const L_AND = "and";
const L_LIMIT = "limit";
const L_IN = "in";
const L_ASC = "asc";
const L_DESC = "desc";
const L_SELECT = "select"
const L_FROM = "from"
const L_WHERE = "where"
const L_ORDER = "order"
const L_BY = "by"
const L_OR = "or"
const L_AND = "and"
const L_LIMIT = "limit"
const L_IN = "in"
const L_ASC = "asc"
const L_DESC = "desc"
47 changes: 23 additions & 24 deletions runtime/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import (
"github.com/cloudson/gitql/parser"
)


func walkCommits(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData, error){
builder.walk, _ = repo.Walk()
builder.walk.PushHead()
builder.walk.Sorting(git.SortTime)
func walkCommits(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData, error) {
builder.walk, _ = repo.Walk()
builder.walk.PushHead()
builder.walk.Sorting(git.SortTime)

s := n.Child.(*parser.NodeSelect)
where := s.Where
Expand Down Expand Up @@ -47,25 +46,25 @@ func walkCommits(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData, er
return true
}

err := builder.walk.Iterate(fn)
if err != nil {
fmt.Printf(err.Error())
}
rowsSliced := rows[len(rows)-counter+1:]
rowsSliced, err = orderTable(rowsSliced, s.Order)
if err != nil {
return nil, err
}
if usingOrder {
if counter > s.Limit {
counter = s.Limit
}
rowsSliced = rowsSliced[0:counter]
}
tableData := new(TableData)
tableData.rows = rowsSliced
tableData.fields = fields
return tableData, nil
err := builder.walk.Iterate(fn)
if err != nil {
fmt.Printf(err.Error())
}
rowsSliced := rows[len(rows)-counter+1:]
rowsSliced, err = orderTable(rowsSliced, s.Order)
if err != nil {
return nil, err
}
if usingOrder {
if counter > s.Limit {
counter = s.Limit
}
rowsSliced = rowsSliced[0:counter]
}
tableData := new(TableData)
tableData.rows = rowsSliced
tableData.fields = fields
return tableData, nil
}

func metadataCommit(identifier string, object *git.Commit) string {
Expand Down
74 changes: 37 additions & 37 deletions runtime/reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/cloudson/gitql/parser"
)

func walkReferences(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData, error){
s := n.Child.(*parser.NodeSelect)
where := s.Where
func walkReferences(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData, error) {
s := n.Child.(*parser.NodeSelect)
where := s.Where

// @TODO make PR with Repository.WalkReference()
iterator, err := builder.repo.NewReferenceIterator()
Expand All @@ -28,40 +28,40 @@ func walkReferences(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData,
}
for object, inTheEnd := iterator.Next(); inTheEnd == nil; object, inTheEnd = iterator.Next() {

builder.setReference(object)
boolRegister = true
visitor.VisitExpr(where)
if boolRegister {
fields := s.Fields
if s.WildCard {
fields = builder.possibleTables[s.Tables[0]]
}
newRow := make(tableRow)
for _, f := range fields {
newRow[f] = metadataReference(f, object)
}
rows = append(rows, newRow)
counter = counter + 1
if !usingOrder && counter > s.Limit {
break
}
}
}
rowsSliced := rows[len(rows)-counter+1:]
rowsSliced, err = orderTable(rowsSliced, s.Order)
if err != nil {
return nil, err
}
if usingOrder {
if counter > s.Limit {
counter = s.Limit
}
rowsSliced = rowsSliced[0:counter]
}
tableData := new(TableData)
tableData.rows = rowsSliced
tableData.fields = fields
return tableData, nil
builder.setReference(object)
boolRegister = true
visitor.VisitExpr(where)
if boolRegister {
fields := s.Fields
if s.WildCard {
fields = builder.possibleTables[s.Tables[0]]
}
newRow := make(tableRow)
for _, f := range fields {
newRow[f] = metadataReference(f, object)
}
rows = append(rows, newRow)
counter = counter + 1
if !usingOrder && counter > s.Limit {
break
}
}
}
rowsSliced := rows[len(rows)-counter+1:]
rowsSliced, err = orderTable(rowsSliced, s.Order)
if err != nil {
return nil, err
}
if usingOrder {
if counter > s.Limit {
counter = s.Limit
}
rowsSliced = rowsSliced[0:counter]
}
tableData := new(TableData)
tableData.rows = rowsSliced
tableData.fields = fields
return tableData, nil
}

func metadataReference(identifier string, object *git.Reference) string {
Expand Down
48 changes: 24 additions & 24 deletions runtime/remotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/cloudson/gitql/parser"
)

func walkRemotes(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData, error){
s := n.Child.(*parser.NodeSelect)
where := s.Where
func walkRemotes(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData, error) {
s := n.Child.(*parser.NodeSelect)
where := s.Where

remoteNames, err := builder.repo.ListRemotes()
if err != nil {
Expand Down Expand Up @@ -43,27 +43,27 @@ func walkRemotes(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData, er
}
rows = append(rows, newRow)

counter = counter + 1
if !usingOrder && counter > s.Limit {
break
}
}
}
rowsSliced := rows[len(rows)-counter+1:]
rowsSliced, err = orderTable(rowsSliced, s.Order)
if err != nil {
return nil, err
}
if usingOrder {
if counter > s.Limit {
counter = s.Limit
}
rowsSliced = rowsSliced[0:counter]
}
tableData := new(TableData)
tableData.rows = rowsSliced
tableData.fields = fields
return tableData, nil
counter = counter + 1
if !usingOrder && counter > s.Limit {
break
}
}
}
rowsSliced := rows[len(rows)-counter+1:]
rowsSliced, err = orderTable(rowsSliced, s.Order)
if err != nil {
return nil, err
}
if usingOrder {
if counter > s.Limit {
counter = s.Limit
}
rowsSliced = rowsSliced[0:counter]
}
tableData := new(TableData)
tableData.rows = rowsSliced
tableData.fields = fields
return tableData, nil
}

func metadataRemote(identifier string, object *git.Remote) string {
Expand Down
2 changes: 1 addition & 1 deletion runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"log"
"os"

"encoding/json"
"github.com/cloudson/git2go"
"github.com/cloudson/gitql/parser"
"github.com/cloudson/gitql/semantical"
"github.com/olekukonko/tablewriter"
"encoding/json"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions runtime/runtime_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package runtime

import (
"path/filepath"
"testing"
"github.com/cloudson/gitql/parser"
"github.com/cloudson/gitql/semantical"
"path/filepath"
"testing"
)

func TestErrorWithInvalidTables(t *testing.T) {
Expand Down

0 comments on commit 9242a1a

Please sign in to comment.