14 ms·
GQL – Git Query Language
- pokstad 3y agoLooks very cool. Does this produce a shell snippet with the appropriate git commands? I like the idea of this being a very thin frontend to git.
- pornel 3y agoit uses gix library, which is a ground-up reimplementation of git, so there's no git CLI involved there at any point.
- chx 3y agoThe concept is interesting but the data exposed makes it kind of hard to run interesting queries. Like, do we have a branch where the last commit was a year ago? Also it seems up arrow doesn't work to recall the previous command?
- grogenaut 3y agoWe have a data lake with our commits at work. I use it to look at developer activity data. Not for performance reasons but to see which of our code bases are active or not. I look at things like iteration time or length a PR/CR sits, number of revisions, etc. This lets me see where we have opportunities to speed up development loops for engineers. Also lets me understand if a service that is having poor performance or growing in cost is under active development. I'll find outliers and go dig into them. This also lets me justify work on tooling because I can quantify the problems and thus the benefits.
- pydry 3y agoThe diff information exposed is also quite anemic - just which files changed.
- dafelst 3y agoThis is a super cool idea, I've been playing with Git internals and having this as a tool/reference will be super helpful. Thanks for sharing! I don't see it in the code, but have you considered creating secondary indexes to speed up some operations? Things like looking up the path of a deleted file in a large repo?
- zffr 3y agoHave you considered using SQLite vtables for this?
- savolai 3y ago+1 Being able to browse with an sqlite ui would be lovely.
- nikeee 3y agoSQLite’s source itself is being managed using Fossil, which uses an SQLite DB as a backing store (instead of a .git directory or similar). That’s a clever use, since the .git dir basically reinvents a database.
- amrdeveloper 3y agoSQLite VTables is great but i want also to have some customization inpsired by MySQL for example user defined variables and functions, maybe add PUSH or PULL Statement and control the features
- shayonj 3y agoTried something similar here: https://github.com/shayonj/branch_base https://github.com/shayonj/branch_base Lmk what you think :)
- bastardoperator 3y agoI like the idea, and I like sql, but I feel like this is a lot more typing for the same information you could extract using just git commands. Am I missing something? Take for instance: The commit example: select name, count(name), from commits group by name is actually: git shortlog -sn The tag example: select * from tags is actually: git tag The branch example: select * from branches is actually: git branch
- snordgren 3y agoIt may be more typing but I can write SQL in my sleep whereas the git CLI I cannot. Though if I regularly needed the information that this tool retrieves I would probably have memorized the relevant CLI commands by now.
- umvi 3y agoSql is a more well known DSL than git CLI
- dtgriscom 3y agoThe git CLI is notoriously irregular, as can be seen by your examples. Having a clean, regular language to query git objects seems valuable.
- esafak 3y agoThis approach falls flat when you start doing analytical queries, and it assumes you already know the git incantations, which most people don't.
- joshuanapoli 3y agoAt least the SQL-like syntax is more consistent. It might be easier to figure out how to make any given query starting from the SQL “schema”.
- paulddraper 3y ago1. SQL is more consistent 2. SQL is more capable 3. SQL is more well-known
- 3y ago
- fragmede 3y agoUnfortunate name, given that GraphQL already exists. https://en.wikipedia.org/wiki/Graph_Query_Language https://en.wikipedia.org/wiki/Graph_Query_Language
- jakewins 3y agoAlso an ISO track thing https://www.gqlstandards.org/ https://www.gqlstandards.org/
- ghusbands 3y agoI've always seen it written as GraphQL, rather than GQL, though that wikipedia page indeed calls it GQL multiple times.
- 8n4vidtmkvmk 3y agoBecause that one is apparently unrelated to GraphQL. Horrible naming.
- Hamuko 3y agoI guess it's not the only unfortunate name considering your link begins with the words "Not to be confused with GraphQL".
- paulddraper 3y agoYou say "GraphQL" but link to "Graph Query Language (GQL)." Those are two entirely separate things. EDIT: And neither of these should be confused with "Graph Query Language (GSQL)" by TigerGraph: https://www.tigergraph.com/gsql/ https://www.tigergraph.com/gsql/
- fragmede 3y agomy mistake points out just how bad a name gql is!
- lloydatkinson 3y agoWhat would a more complex query look like with that, for example, querying for any commit that affected any file in a list of files, by a specific author?
- setheron 3y agoApache Calcite has this as an integration as does SQLite though virtual tables. Nonetheless nice work
- jakubmazanec 3y agoWhy would someone use SQL, famously bad language, as a query language for git, famously badly designed CLI?
- mpalmer 3y ago"Famously bad" is an opinion cloaked in adverbial authority. Plenty of people like both, and even if they don't like them, they think better in one vs the other.
- 8n4vidtmkvmk 3y agoSQL is ok, it just needs to be refined a bit. This was such an opportunity but they didn't cease it.
- avgcorrection 3y agoThat git(1) (the user interface) is badly designed is an opinion shared by many people, including many on the Git mailing list. Backwards compatibility is mostly used to argue for the status quo, not that the status quo is good.
- mpalmer 3y agoAll the more reason for alternative interfaces.
- onionisafruit 3y agoI like your phrase “adverbial authority”
- amrdeveloper 3y agoFor Me I Think SQL is great for most of the features here and the most important is that people don't need to learn a new full language to use GitQL
- ebfe1 3y agoLovely! I only learnt today that clickhouse has a git-import tool from my colleagues at ClickHouse. So if you also want to give it a go: Download clickhouse: curl https://clickhouse.com/ https://clickhouse.com/ | sh Check out documentation for git-import: ./clickhouse git-import --help Then the tool can be run directly inside the git repository. It will collect data like commits, file changes and changes of every line in every file for further analysis. It works well even on largest repositories like Linux or Chromium. Example of a trivial query: SELECT author AS k, count() AS c FROM line_changes WHERE file_extension IN ('h', 'cpp') GROUP BY k ORDER BY c DESC LIMIT 20 Example of some non-trivial query - a matrix of authors, how much code of one author is removed by another: SELECT k, written_code.c, removed_code.c, round(removed_code.c * 100 / written_code.c) AS remove_ratio FROM ( SELECT author AS k, count() AS c FROM line_changes WHERE sign = 1 AND file_extension IN ('h', 'cpp') AND line_type NOT IN ('Punct', 'Empty') GROUP BY k ) AS written_code INNER JOIN ( SELECT prev_author AS k, count() AS c FROM line_changes WHERE sign = -1 AND file_extension IN ('h', 'cpp') AND line_type NOT IN ('Punct', 'Empty') AND author != prev_author GROUP BY k ) AS removed_code USING (k) WHERE written_code.c > 1000 ORDER BY c DESC LIMIT 500
- koolba 3y ago> Download clickhouse: curl https://clickhouse.com/ https://clickhouse.com/ | sh Does this check the useragent to change the response? Clicking that link shows their home page.
- ebfe1 3y agothat is exaxtly what it does ;) if you don't feel comfortable with curl | sh , you can download clickhouse binary from the repo here https://github.com/ClickHouse/ClickHouse/releases https://github.com/ClickHouse/ClickHouse/releases ;)
- pcthrowaway 3y agoChanging the content from an html page to a shell script based on user-agent is a pretty bad abuse of HTTP. Why not at least require `-H 'Accept: text/x-shellscript'`? Or be more basic and give the script its own URL
- nittanymount 3y agothis seems converting graph/tree data model to relational data model ? hmm...
- ellisv 3y agoLooks cool. Reminds me of Steampipe except this works on a local git repository.
- cglendenning 3y agoYESSSS!! All those years of tuning queries paid off. I knew SQL was immortal.
- hot_gril 3y agoWe have a special language for monitoring our metrics at work. It's fussy and obscure. I replaced it with SQL on our team, which despite "not being good for timeseries data" works fine for this.
- it 3y agoAnd it will be called "geequal".
- gingerwizard 3y agoSome good examples and docs on this data https://clickhouse.com/docs/en/getting-started/example-datasets/github https://clickhouse.com/docs/en/getting-started/example-datas...
- grogenaut 3y agoWould be cool to have duckdb be able to read git commit history as a data source.
- Sargos 3y agoUnfortunately this is going to need a name change, or at least modified initials, as GQL is for Graph Query Language [https://www.gqlstandards.org/ https://www.gqlstandards.org/] which is being standardized and will be the primary way the world uses Property Graphs like Neo4j. Can't compete with that.
- zubairq 3y agoLooks pretty awesome. gonna try it!
- UltraMagnus 3y agoAmazing work! Just tried it out on a couple of my repos and it works great. Thank you, starred on Github ;) I would like to request a feature --> Can you allow the output produced by GQL to be in different serializable formats, like JSON? I see a lot of potential to this if the GQL output could be piped to C# LINQ queries.
- ezst 3y agoPardon my imprudence here, but it looks way worse than Mercurial's templates and revsets: https://repo.mercurial-scm.org/hg/help/template https://repo.mercurial-scm.org/hg/help/template https://repo.mercurial-scm.org/hg/help/revset https://repo.mercurial-scm.org/hg/help/revset (but arguably enables few things like aggregations that would require the churn extension)