diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8688f97..5baa2d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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 diff --git a/cmd.go b/cmd.go index ba4e985..cd63721 100644 --- a/cmd.go +++ b/cmd.go @@ -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 } @@ -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") } @@ -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 `) diff --git a/runtime/reference.go b/runtime/reference.go index b2c4b25..41564cd 100644 --- a/runtime/reference.go +++ b/runtime/reference.go @@ -1,10 +1,10 @@ package runtime import ( - "strconv" "log" + "strconv" - "github.com/cloudson/git2go" + git "github.com/cloudson/git2go" "github.com/cloudson/gitql/parser" ) @@ -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) } @@ -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 } diff --git a/runtime/runtime.go b/runtime/runtime.go index 8bab4a1..909a785 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -16,7 +16,6 @@ import ( const ( WALK_COMMITS = 1 WALK_REFERENCES = 2 - WALK_REMOTES = 3 ) const ( @@ -47,7 +46,6 @@ type GitBuilder struct { currentWalkType uint8 currentCommit *git.Commit currentReference *git.Reference - currentRemote *git.Remote walk *git.RevWalk } @@ -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 } @@ -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 { @@ -295,12 +287,6 @@ func PossibleTables() map[string][]string { "type", "hash", }, - "remotes": { - "name", - "url", - "push_url", - "owner", - }, "tags": { "name", "full_name", diff --git a/tables.md b/tables.md index 879ca61..7c44fed 100644 --- a/tables.md +++ b/tables.md @@ -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 |