Skip to content

Commit

Permalink
Prepare v2.0.0
Browse files Browse the repository at this point in the history
- remove support to remotes
- use fixed version of OS on github actions
- set short and long flags for cli
  • Loading branch information
filhodanuvem committed Oct 27, 2019
1 parent 7d23679 commit fae8122
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 43 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: [push]
jobs:
build-linux:
name: Build linux
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps:
- name: Set up Go 1.12
uses: actions/setup-go@v1
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:

build-mac:
name: Build mac
runs-on: macos-latest
runs-on: macOS-10.14
steps:
- name: Set up Go 1.12
uses: actions/setup-go@v1
Expand Down Expand Up @@ -90,7 +90,6 @@ jobs:
TARGET_OS_ARCH: windows/amd64
run: |
choco install ninja vcredist2017
set PATH=%HOMEDRIVE%\mingw64\bin;%PATH%
make build
.\gitql.exe -v
Expand Down
25 changes: 14 additions & 11 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import (
"github.com/pkg/errors"
)

const Version = "Gitql 1.6.0"
const Version = "Gitql 2.0.0"

type Gitql struct {
Path string `short:"p" default:"."`
Version bool `short:"v"`
Isinteractive bool `short:"i"`
ShowTables bool `long:"show-tables"`
TypeFormat string `long:"type" default:"table"`
Help bool `short:"h" long:"help"`
Version bool `short:"v" long:"version"`
Isinteractive bool `short:"i" long:"interactive"`
ShowTables bool `short:"s" long:"show-tables"`
TypeFormat string `short:"f" long:"type" default:"table"`
Query string
}

Expand Down Expand Up @@ -125,10 +126,11 @@ func (cmd *Gitql) parse(argv []string) error {
args, err := p.ParseArgs(argv)

if err != nil {
os.Stderr.Write(cmd.usage())
return err
}

if !cmd.Isinteractive && !cmd.Version && !cmd.ShowTables && len(args) == 0 {
if cmd.Help || (!cmd.Isinteractive && !cmd.Version && !cmd.ShowTables && len(args) == 0) {
os.Stderr.Write(cmd.usage())
return errors.New("invalid command line options")
}
Expand All @@ -144,14 +146,15 @@ func (cmd Gitql) usage() []byte {
Usage: gitql [flags] [args]
Flags:
-i Enter to interactive mode
-p string
-i --interactive Enter to interactive mode
-p --path string
The (optional) path to run gitql (default ".")
--show-tables
-s --show-tables
Show all tables
--type string
-f --type string
The output type format {table|json} (default "table")
-v The version of gitql
-v --version The version of gitql
-h --help this help
Arguments:
sql: A query to run
`)
Expand Down
10 changes: 3 additions & 7 deletions runtime/reference.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package runtime

import (
"strconv"
"log"
"strconv"

"github.com/cloudson/git2go"
git "github.com/cloudson/git2go"
"github.com/cloudson/gitql/parser"
)

Expand Down Expand Up @@ -53,7 +53,7 @@ func walkReferences(n *parser.NodeProgram, visitor *RuntimeVisitor) (*TableData,
if s.Count {
newRow := make(tableRow)
// counter was started from 1!
newRow[COUNT_FIELD_NAME] = strconv.Itoa(counter-1)
newRow[COUNT_FIELD_NAME] = strconv.Itoa(counter - 1)
counter = 2
rows = append(rows, newRow)
}
Expand Down Expand Up @@ -98,10 +98,6 @@ func metadataReference(identifier string, object *git.Reference) string {
return REFERENCE_TYPE_BRANCH
}

if object.IsRemote() {
return REFERENCE_TYPE_REMOTE
}

if object.IsTag() {
return REFERENCE_TYPE_TAG
}
Expand Down
14 changes: 0 additions & 14 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
const (
WALK_COMMITS = 1
WALK_REFERENCES = 2
WALK_REMOTES = 3
)

const (
Expand Down Expand Up @@ -47,7 +46,6 @@ type GitBuilder struct {
currentWalkType uint8
currentCommit *git.Commit
currentReference *git.Reference
currentRemote *git.Remote
walk *git.RevWalk
}

Expand Down Expand Up @@ -116,8 +114,6 @@ func findWalkType(n *parser.NodeProgram) uint8 {
switch s.Tables[0] {
case "commits":
builder.currentWalkType = WALK_COMMITS
case "remotes":
builder.currentWalkType = WALK_REMOTES
case "refs", "tags", "branches":
builder.currentWalkType = WALK_REFERENCES
}
Expand Down Expand Up @@ -248,10 +244,6 @@ func (g *GitBuilder) setReference(object *git.Reference) {
g.currentReference = object
}

func (g *GitBuilder) setRemote(object *git.Remote) {
g.currentRemote = object
}

func (g *GitBuilder) WithTable(tableName string, alias string) error {
err := g.isValidTable(tableName)
if err != nil {
Expand Down Expand Up @@ -295,12 +287,6 @@ func PossibleTables() map[string][]string {
"type",
"hash",
},
"remotes": {
"name",
"url",
"push_url",
"owner",
},
"tags": {
"name",
"full_name",
Expand Down
8 changes: 0 additions & 8 deletions tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ Gitql [![Build Status](https://travis-ci.org/cloudson/gitql.png)](https://travis
| message |
| full_message |

| remotes |
| ---------|
| name |
| url |
| push_url |
| owner |


| tags |
| ---------|
| name |
Expand Down

0 comments on commit fae8122

Please sign in to comment.