💊 A git query language

Overview

Gitql Go Report Card Open Source Helpers License MIT

Gitql is a Git query language.

In a repository path...

how to use

See more here

Reading the code

⚠️ This project was created in 2014 as my first go project. Use this project to learn about how to structure go code is not a good idea. You can read a much modern code from mine here or help me guiding this one to the right direction.

Requirements

  • Go

How to install

You can access the releases page and just grab the binary. If you want to compile itself just run go build ..

Examples

gitql "your query"
or
git ql "your query"

As an example, this is the commits table:

commits
author
author_email
committer
committer_email
hash
date
message
full_message

(see more tables here)

Example Commands

  • select hash, author, message from commits limit 3
  • select hash, message from commits where 'hell' in full_message or 'Fuck' in full_message
  • select hash, message, author_email from commits where author = 'cloudson'
  • select date, message from commits where date < '2014-04-10'
  • select message from commits where 'hell' in message order by date asc
  • select distinct author from commits where date < '2020-01-01'

Questions?

gitql or open an issue

Notes:

  • Gitql doesn't want to kill git log - it was created just for science! 😅
  • It's read-only - no deleting, inserting, or updating tables or commits. 😝
  • The default limit is 10 rows.
  • It's inspired by textql.
  • Gitql is a compiler/interpreter instead of just read a sqlite database with all commits, tags, etc. because we would need to sync the tables every time before run sql and we would have sqlite bases for each repository. 😐
Comments
  • Add support to count commits

    Add support to count commits

    This one is for issue #26 (implement COUNT). So far not all test suites are updated, otherwise it seem to work. Please review when you have time, meanwhile I'll update missing tests in a day or two.

    opened by budden 14
  • Can't build on Windows with Git bash and MinGW

    Can't build on Windows with Git bash and MinGW

    opened by jcubic 12
  • Option to export git log to sqlite

    Option to export git log to sqlite

    When this command runs it creates an in memory sqlite database with all tables and throws us in the sqlite3 shell (possibly with --dump, which simply stores the tables in a sqlite db disc based file). This will allow much richer query.

    discuss 
    opened by amitu 12
  • Adding interactive mode

    Adding interactive mode

    What I did?

    • Added interactive mode
    • Fixed so that it can be executed without passing it as a string argument. like gitql select hash, author, message from commits
    opened by Code-Hex 12
  • Adding support to json

    Adding support to json

    This PR adds support to json as per https://github.com/cloudson/gitql/issues/27

    I also created a flag -json // not sure if it is the best name for the flag

    In this way:

    • git ql "select author,hash from commits" returns the classic table as its output.
    • git ql -json "select author,hash from commits" returns a json as its output.

    Please check the image below:

    gitsql_json

    enhancement 
    opened by luizperes 12
  • Add 'like' functionality in where clause

    Add 'like' functionality in where clause

    Fixes may be first part of #59

    gitql 'select message, author from commits where message like "%author%"'
    +--------------------------------+----------+
    |            message             |  author  |
    +--------------------------------+----------+
    | support for full_message,      | cloudson |
    | message, author, committer     |          |
    +--------------------------------+----------+
    
    opened by jsixface 8
  • Error when I use the plugin

    Error when I use the plugin

    dyld: Library not loaded: libgit2.21.dylib Referenced from: /usr/local/bin/gitql Reason: image not found [1] 56160 abort gitql "select message from commits"

    I'm on Mac OSX

    opened by piclemx 8
  • building from src on OS/X (and/or installing)

    building from src on OS/X (and/or installing)

    After makeing on Mac, fails with *.dyld thus:

    $ ./gitql 'select author, message, hash from commits where "travis" in message'
    dyld: Library not loaded: libgit2.21.dylib
      Referenced from: ${GOPATH}/src/github.com/cloudson/gitql/./gitql
      Reason: image not found
    Abort trap: 6
    

    According to apple developer docs, you should be able to set any of LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, or DYLD_FALLBACK_LIBRARY_PATH.

    but for me (on Sierra 10.12.1), only the last two work.

    An alternative not requiring an environment variable is to install the libraries (link them) in /usr/local/lib.

    Running this post-installation script from the same directory as make, on Mac works for me. I'll leave it to you to edit the echo out.

    for i in  $(PWD)/libgit2/install/lib/lib*
    do
        targ="$(basename $i)"
        bn=$targ
        dn="$(dirname $i)"
        [ -L "$i" ] && targ="$(readlink $i)"
        echo "ln -s $dn/$targ /usr/local/lib/$bn"
    done
    

    Note: If you ever run make clean from the build directory, your installed commands will stop working, so it may be wiser to copy the two main *.dyld files into /usr/local/bin, and link everything else back to them. Doing that could look something like this:

    for i in  $(PWD)/libgit2/install/lib/lib*
    do
        [ -L "$i" ] && echo "ln -s /usr/local/lib/$(readlink $i) /usr/local/lib/${sr}" \
                        || echo "cp $i /usr/local/lib"
    done
    
    opened by yarko 8
  • Display of multiline commit messages

    Display of multiline commit messages

    When a commit message is spread over multiple lines E.g.:

    This is first line of message:
    * Second
    * Third
    

    Then only the first line This is first line of message: gets output in the table.

    bug 
    opened by jamescowie 7
  • Installation on mac os x

    Installation on mac os x

    Great idea!

    I have a problem with installation, after I've done everything by instruction, and then tried

    gitql

    I've got the next one:

    dyld: Library not loaded: libgit2.0.dylib Referenced from: /usr/local/bin/gitql Reason: image not found Trace/BPT trap: 5

    Any idea how to fix that quickly?

    bug discuss 
    opened by feversocial 7
  • Bug: Application panics on query with double quotes

    Bug: Application panics on query with double quotes

    This query works fine

    gitql "select author, message, date from commits where author like 'Oliveira'"
    

    This one, with a double quotes in the where clause raises an error

    gitql "select author, message, date from commits where author like "Oliveira""
    
    panic: interface conversion: parser.NodeExpr is *parser.NodeId, not *parser.NodeLiteral
    
    goroutine 1 [running]:
    github.com/cloudson/gitql/parser.gWC4(0xc000175b00, 0x167734b, 0x6, 0x169a8e8, 0x6)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/parser/parser.go:503 +0x6ce
    github.com/cloudson/gitql/parser.gWC3(0x1b42700, 0x1, 0x1, 0xc0000ad29a, 0x6)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/parser/parser.go:429 +0x37
    github.com/cloudson/gitql/parser.gWC2(0x1b42700, 0x1, 0x1b427c0, 0xc0000ad29a, 0x6)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/parser/parser.go:403 +0x37
    github.com/cloudson/gitql/parser.gWhereConds(0x15, 0x0, 0x3, 0xc00013b520)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/parser/parser.go:386 +0x26
    github.com/cloudson/gitql/parser.gWhere(0xc00013b520, 0x1, 0x1, 0x0)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/parser/parser.go:380 +0x6b
    github.com/cloudson/gitql/parser.gSelect(0x1, 0x0, 0xc000175c98)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/parser/parser.go:119 +0x117
    github.com/cloudson/gitql/parser.gProgram(0x7ffeefbffaa6, 0x44, 0xc0000bd348, 0xc000175d18)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/parser/parser.go:64 +0x1b4
    github.com/cloudson/gitql/parser.AST(...)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/parser/parser.go:46
    main.runQuery(0x7ffeefbffaa6, 0x44, 0x1674e2d, 0x1, 0x16764d2, 0x5, 0x1b76da0, 0xc000194200)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/main.go:158 +0x89
    main.main.func2(0xc000192140, 0x7ffeefbffaa6, 0x44)
    	/Users/runner/work/gitql/go/src/github.com/cloudson/gitql/main.go:101 +0x2a7
    github.com/urfave/cli/v2.(*App).RunContext(0xc0000be300, 0x174a5e0, 0xc0000ac000, 0xc0000a8000, 0x2, 0x2, 0x0, 0x0)
    	/Users/runner/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:315 +0x6bf
    github.com/urfave/cli/v2.(*App).Run(...)
    
    hacktoberfest 
    opened by filhodanuvem 6
  • Is count supported?

    Is count supported?

    i tried to use count in SQL but got an error:

    gitql> select author, count(author) as count from commits group by author
    Error: Expected T_ID and found T_COUNT
    

    So is count is not supported yet?

    opened by xuegl 3
  • Benchmarks

    Benchmarks

    The idea of this issue is exactly what we had on https://github.com/filhodanuvem/gitql/issues/23, I'm duplicating it as an upvote with the hope that we are getting some contribution on hacktoberfest21.

    What we expect is to see some numbers on how gitql behaves with big repositories such as kubernetes. Does the queries with filtering take longer to respond? Some ideas on how this could be achieved:

    • Use the go testing package to create some benchmarks from the source code point of view ( against the function runtime.runQuery() )
    • Any other benchmark tool (pure bash script is also accepted)
    • Run the benchmark on every merge on GitHub Actions, if possible mark the job as allow_failure.
    hacktoberfest 
    opened by filhodanuvem 0
  • Bug: Functional tests do not run on windows VM

    Bug: Functional tests do not run on windows VM

    We use bats to run functional tests on GitHub Actions. But the action is failing in the setup only on Windows VMs. This might be a problem in the action version itself or it is not well configured.

    C:\Windows\system32\tar.exe xz -C D:\a\_temp\443effea-912b-4f54-b64f-2707d310082a -f D:\a\_temp\c91d5722-6f45-42f2-b33d-4d132f5d8de8
    bats-core-1.2.1/test/fixtures/parallel/setup_file/setup_file1.bats: Can't create '\\\\?\\D:\\a\\_temp\\443effea-912b-4f54-b64f-2707d310082a\\bats-core-1.2.1\\test\\fixtures\\parallel\\setup_file\\setup_file1.bats'
    bats-core-1.2.1/test/fixtures/parallel/setup_file/setup_file2.bats: Can't create '\\\\?\\D:\\a\\_temp\\443effea-912b-4f54-b64f-2707d310082a\\bats-core-1.2.1\\test\\fixtures\\parallel\\setup_file\\setup_file2.bats'
    bats-core-1.2.1/test/fixtures/parallel/setup_file/setup_file3.bats: Can't create '\\\\?\\D:\\a\\_temp\\443effea-912b-4f54-b64f-2707d310082a\\bats-core-1.2.1\\test\\fixtures\\parallel\\setup_file\\setup_file3.bats'
    bats-core-1.2.1/test/fixtures/parallel/suite/parallel1.bats: Can't create '\\\\?\\D:\\a\\_temp\\443effea-912b-4f54-b64f-2707d310082a\\bats-core-1.2.1\\test\\fixtures\\parallel\\suite\\parallel1.bats'
    bats-core-1.2.1/test/fixtures/parallel/suite/parallel2.bats: Can't create '\\\\?\\D:\\a\\_temp\\443effea-912b-4f54-b64f-2707d310082a\\bats-core-1.2.1\\test\\fixtures\\parallel\\suite\\parallel2.bats'
    bats-core-1.2.1/test/fixtures/parallel/suite/parallel3.bats: Can't create '\\\\?\\D:\\a\\_temp\\443effea-912b-4f54-b64f-2707d310082a\\bats-core-1.2.1\\test\\fixtures\\parallel\\suite\\parallel3.bats'
    bats-core-1.2.1/test/fixtures/parallel/suite/parallel4.bats: Can't create '\\\\?\\D:\\a\\_temp\\443effea-912b-4f54-b64f-2707d310082a\\bats-core-1.2.1\\test\\fixtures\\parallel\\suite\\parallel4.bats'
    tar.exe: Error exit delayed from previous errors.
    Error: The process 'C:\Windows\system32\tar.exe' failed with exit code 1
    

    I've opened a PR to show how can you test that. https://github.com/filhodanuvem/gitql/pull/131 https://github.com/filhodanuvem/gitql/runs/3886290856?check_suite_focus=true

    hacktoberfest 
    opened by filhodanuvem 2
  • Improve code coverage

    Improve code coverage

    I think this project has quite good test coverage already, from looking through some test files. Still it could be nice with a ticket find the current coverage, and to figure out together if some more tests should be added.

    opened by sesam 1
Releases(v2.3.0)
Owner
Claudson Oliveira
Observer, Urban dance student, Philosopher after drinking, Youtuber and Software lover
Claudson Oliveira
A CLI to replace your git commit command, so your git message can partially follow the Conventional Changelog ecosystem

COMMIT CLI A CLI to replace your git commit command, so your git message can partially follow the Conventional Changelog ecosystem. And yes, it is bui

Hisam Fahri 1 Feb 9, 2022
git-glimpse is a command-line tool that is aimed at generating a git prompt like the one from zsh-vcs-prompt.

Git GoGlimpse git-glimpse is a command-line tool that is aimed at generating a git prompt like the one from zsh-vcs-prompt. The particularity of this

Corentin de Boisset 0 Jan 27, 2022
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.

dasel Dasel (short for data-selector) allows you to query and modify data structures using selector strings. Comparable to jq / yq, but supports JSON,

Tom Wright 3.7k Sep 25, 2022
Pi-hole data right from your terminal. Live updating view, query history extraction and more!

Pi-CLI Pi-CLI is a command line program used to view data from a Pi-Hole instance directly in your terminal.

Reece Mercer 41 Apr 26, 2022
fofax is a fofa query tool written in go, positioned as a command-line tool and characterized by simplicity and speed.

fofaX 0x00 Introduction fofax is a fofa query tool written in go, positioned as

null 461 Sep 24, 2022
Oslatlong - CLI to query OSM Nominatim API

oslatlong Quickly conceived app to query OSM's Nominatim geocoding API. How do I

Omachonu Ogali 4 Jul 21, 2022
A very simple note-taking CLI you can use from the terminal that uses a SQLite DB to persist, and query, notes.

Note Logger Summary A very simple note-taking CLI you can use from the terminal that uses a SQLite DB to persist, and query, notes. Building/Installin

Nicholas Page 3 Apr 14, 2022
Simple, seamless, lightweight time tracking for Git

Git Time Metric Seamless time tracking for all your Git projects $ gtm report -last-month $ gtm report -last-month -format summary $ gtm report -last-

Git Time Metric 905 Sep 16, 2022
commit/branch/workdir explorer for git

gitin gitin is a commit/branch/status explorer for git gitin is a minimalist tool that lets you explore a git repository from the command line. You ca

Ibrahim Serdar Acikgoz 1.8k Sep 24, 2022
Modern ls command with vscode like File Icon and Git Integrations. Written in Golang

logo-ls modern ls command with beautiful Icons and Git Integrations . Written in Golang Command and Arguments supported are listed in HELP.md Table of

Yash Handa 919 Sep 24, 2022
A tiny git forge written in Go

Smithy smithy (n) A blacksmith's shop; a forge. Smithy is a web frontend for git repositories. It's implemented entirely in Golang, compiles to a sing

Honza Pokorny 203 Sep 10, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Gruntwork 650 Sep 28, 2022
A better way to clone, organize and manage multiple git repositories

git-get git-get is a better way to clone, organize and manage multiple git repositories. git-get Description Installation macOS Linux Windows Usage gi

Greg Dlugoszewski 61 Aug 31, 2022
Bit is a modern Git CLI

bit is an experimental modernized git CLI built on top of git that provides happy defaults and other niceties: command and flag suggestions to help yo

Chris Walz 5.9k Sep 26, 2022
Interactive CLI helper for creating git branches with JIRA Links and some text

bb (better-branch) Interactive CLI helper for creating git branches with JIRA Links and some text Still in development? Yes How it works? This tiny ut

Eugene Uvarov 3 Aug 18, 2022
A command line http test tool. Maintain the case via git and pure text

httptest A command line http test tool Maintain the api test cases via git and pure text We want to test the APIs via http requests and assert the res

wklken 12 Aug 4, 2022
Contextual information about your git projects, right on the command-line

gitty gitty is a smart little CLI helper for git projects, that shows you all the relevant issues, pull requests and changes at a quick glance. It cur

Christian Muehlhaeuser 393 Sep 16, 2022
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command. You give git-xargs:

Maxar Infrastructure 1 Feb 5, 2022
A dead simple cli utility to help you manage your git stash

A dead simple cli utility to help you manage your git stash.

Fadi Khadra 3 Aug 2, 2022