7 ms·
A Git query language
- rodorgas 10y agoThat's a great idea!
- taspeotis 10y agoA Git query language (github.com) 10 points by bryanrasmussen 1 hour ago This ought to have (2014) in the title: Latest commit 49c1c17 on 22 Jun 2014.
- patkai 10y agoThat makes it even more interesting, I mean the fact that this or something similar didn't get traction. I often have an idea of what I would like to know about my repo, but don't want to start hacking the answer together.
- OJFord 10y agohttps://github.com/gitql/gitql https://github.com/gitql/gitql (last commit 12 days ago)
- bryanrasmussen 10y agosorry, didn't note the date, I just found it because I was needing something like it and was ready to start making it because I figured - better look if someone else did the work for me first.
- koolba 10y agoThis is pretty cool. Looks like it's local to the current repo which makes sense for most usage. Having something like this across a swathe of repos would be useful in different ways (ex: "What has Bob committed over all the repos for our projects that involves the string 'billing'?". Minor off topic rant about the animated example: Who doesn't put a space at the end of their prompt after the $?! Ugh!
- OJFord 10y ago> Who doesn't put a space at the end of their prompt after the $?! Ugh! I've always had mixed feelings about that. Resolved it now, by using '>', no space, which doesn't look cluttered since there's only ~1px right next to the first char entered.
- iagooar 10y agoI agree. Since we work with microservices, we have +10 repo per project. Would be nice to be able to scan through all of them.
- OJFord 10y agoYou could submodule them all in an otherwise empty parent repo. Bit of a hack, but could come in handy for other things (off the top of my head: "welcome to the team! Clone this one thing, it contains everything you need.").
- nothrabannosir 10y agoPlug: if you ever find yourself wanting to merge everything painlessly: https://github.com/unravelin/tomono https://github.com/unravelin/tomono :) accompanying blog post: https://syslog.ravelin.com/multi-to-mono-repository-c81d004df3ce https://syslog.ravelin.com/multi-to-mono-repository-c81d004d...
- icefox 10y agoGit map would work for many cases https://github.com/icefox/git-map https://github.com/icefox/git-map Git map ql ...
- oneeyedpigeon 10y agoImagine if we could just have this automatically for every program that generated text output. It doesn't seem beyond the realms of possibility that every tool could either a) structure its text output in a way that can guarantee simple command-piping to a general purpose query-language processing tool or b) in the presence of a "--output-json" flag, produce json which can then easily be queried.
- shakna 10y agoSounds like you'd like the object-based Powershell.
- junke 10y agoOr you could have a single address space (https://en.wikipedia.org/wiki/Single_address_space_operating_system https://en.wikipedia.org/wiki/Single_address_space_operating...), and share objects directly.
- donut 10y agoIt's the UNIX principle/tradition that line oriented text is the universal format. It's quite flexible. But I share your feeling, and I keep hearing nice things about powershell. Also, if you work with CSV files, look at textql.
- c8g 10y agoactive gitql https://github.com/gitql/gitql https://github.com/gitql/gitql
- mnovaes 10y agoThis one actually seems very promising.
- somebehemoth 10y agoThank you for sharing this. I was interested to know if this was a fork of gitql by cloudson. It is not. The following issue clarifies the relationship: https://github.com/gitql/gitql/issues/83 https://github.com/gitql/gitql/issues/83 "The relation is its purpose: SQL + Git, written in Go. There is no relation other than that." I thought this might help anyone else who was similarly interested.
- deleted 10y ago[deleted]
- masklinn 10y agoMercurial has a somewhat similar concept predating this (added circa 2010): revision sets (https://www.selenic.com/mercurial/hg.1.html#revsets https://www.selenic.com/mercurial/hg.1.html#revsets) (for selection, and templates for selection but git has that built-in, kind-of, via log --format)
- jordigh 10y agoMercurial's are completely general, though. Any Mercurial command that can accept a revision as an argument can also accept a revset expression. And templating isn't just for log, but for many other commands, such as grep or annotate (blame), and it's the same templating language for all of them. I also find hg templates a bit easier to read, because they're Djangoish/Jinjaish instead of being printf-ish like git's. Plus, you can save and compose Mercurial templates and revsets. I was actually hoping that gitql had finally gotten inspiration from Mercurial and git would grow a general purpose query language, but it's read-only. :-(
- aardvark179 10y agoRevsets are a wonderful feature, and it's something I wish git had. Just being able to say I want to see what has changed between this branch head and its latest common ancestor with trunk is an incredibly simple and useful thing to be able to do.
- trolor 10y agoComplete guess based on [1], but wouldn't git diff HEAD $(git merge-base HEAD master) work? [1]: https://stackoverflow.com/questions/1549146/find-common-ancestor-of-two-branches https://stackoverflow.com/questions/1549146/find-common-ance...
- aardvark179 10y agoIn this case git can do the same thing, but notice you can only do it because git provides a special command for getting that revision. Recasts are really general (a greatest common ancestor function is provided, but can be easily synthesised from more primitive building blocks) and can be used everywhere, so you can bisect over changes you made that touched files matching a pattern, or whatever. They aren't something I use every day, but they are really useful on occasions and allow for some pretty robust tooling to be written.
- Erwin 10y agoThis might benefit from SQLite's Virtual tables: https://sqlite.org/vtab.html https://sqlite.org/vtab.html With Virtual Tables you can expose any data source as a SQLite table -- then you can use every SQL feature that sqlite offers. You can just tell sqlite how to iterate through your data with a few functions, with an option to push down filtering information for efficiency. You can also create your own aggregates, functions etc. Here's an article where the author exposes redis as a table within sqlite: http://charlesleifer.com/blog/extending-sqlite-with-python/ http://charlesleifer.com/blog/extending-sqlite-with-python/
- erydo 10y agoMy thoughts went straight to PostgreSQL Foreign Data Wrappers. Something like that would be really helpful!
- andrewstuart2 10y agoWouldn't that require a running Postgres server, though? Seems a bit heavy for ad hoc queries. For something like a GitLab server, though, that would be amazing.
- deleted 10y ago[deleted]
- oneweekwonder 10y agoAccording to the Ubuntu Dependencies[0] it already uses Postgres, it also needs Redis, so with gitlab we are a bit pass the heavy bit. [0]: http://packages.ubuntu.com/xenial/gitlab http://packages.ubuntu.com/xenial/gitlab
- simonw 10y agoSQLite virtual tables for git would be phenomenal - you could join your git history against data from other sources! And you wouldn't need to run a huge MySQL/Postgres server process to do it. A very cursory search suggests no one has built this yet.
- guard-of-terra 10y agoBut why does it have to look like SQL (and not like xpath or jquery)? Not many people enjoy writing SQL statements on the command line. It's verbose, the order of things is arbitrary...
- mwfunk 10y agoI would assume that the whole point of the project is to be able to do SQLish queries on a git repo, and that it was written by and for people who are familiar with SQL and have a preference for it over other query languages. And they probably do enjoy writing SQL statements on the command line, however uncommon that may or may not be.
- guard-of-terra 10y agoSeems to be very narrow group. How is this relevant to HN? Flagged the story.
- jsmeaton 10y agoYou flagged the story because you don't like SQL on the CLI? Come on. Whether or not you enjoy writing SQL on the CLI, SQL is a fine language for querying data, and is probably more common than xpath. JQuery seems like a strange choice too.
- guard-of-terra 10y agoI just fail to praise the attitude. "Let's faithfully reproduce the looks of 30 y.o. technology, pseudographic tables included, with make-believe over git".
- Rudisimo 10y agoWell, if you feel so strongly about it, why not build your own tool to support the "preferred" query language?
- ujjwal_wadhawan 10y agosupport for "SELECT DISTINCT" would be great !
- ecesena 10y agoIt would be nice to see a plugin for presto
- Tarean 10y agoVery cool. I always wanted to play around with a git provider for powershell. Powershell's syntax is great for queries and you could use everything that works on the normal file system with anything that has the abstractions implemented. The syntax seems close enough that this could just replace it, though: ls commits | where date < (get-date).AddDays(-4) | where message -like *foo* | select autor, message, date -First 3 | ft
- chadgeidel 10y agoI'm no powershell guru, but I'm using posh-git [1]. Is it possible to chain commands using that tool? https://github.com/dahlbyk/posh-git https://github.com/dahlbyk/posh-git
- odammit 10y agoOh I love that the example gif includes: select author, message from commits where 'Fuck' in message I'm pretty sure that query's results would fill my screen buffer.
- seliopou 10y agoThis can easily be accomplished using `git log`, `head`, and `grep`: git log --pretty="format:%an, %s, %ad" --after="2014-04-10" | grep "Fuck" | head -3
- georgewfraser 10y agoIf you actually want to query git data in production, it's really a better idea to copy all the data into a real SQL data warehouse. If you're using github, my company (Fivetran.com) has a connector that pulls from their API.
- andrewchambers 10y agoI don't see the point in wrapping the data in all that ascii art noise, will make it harder to script with.
- 0x54MUR41 10y agoWow. It's awesome. I have never been seen project like this before. It seems very useful. Anyway, I think it would be better if they demonstrate the example of usage using asciinema [1]. [1]: https://asciinema.org https://asciinema.org