4 ms·
Git2graph: Generate a Git graph structure from linear Git history
- cbarrick 6y agoThe input format is json? How do I generate that from a git log?
- pwdisswordfish0 6y agoThat was my first thought, too. But the input is not JSON. The input is an object graph. JSON stands for "JS Object Notation". Any graph with nodes that match the shape that the example JSON parses to is a valid input. (Though it doesn't help that the author refers to the graph as "json".) Still, getting that object graph is the other half of the owl.
- alain_gilbert 6y agoIt's been a while I haven't work on this, but if you do 'git2graph -r' within a repository folder, I believe it will generate the needed json for that repository.
- vsareto 6y agoSomething like these? https://stackoverflow.com/questions/4600445/git-log-output-to-xml-json-or-yaml https://stackoverflow.com/questions/4600445/git-log-output-t... https://gist.github.com/textarcana/1306223 https://gist.github.com/textarcana/1306223
- jrib 6y agoNice. I've had this in my ~/.gitconfig for a while for cases where I want to see how branches merged in my history: [alias] lg = log --graph --pretty=format:'%C(red)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)[%an]%Creset'
- alain_gilbert 6y agoThe goal of this library was not to visualize the graph, but to embed it in your own software. So if you want to use cairo to render the graph in your native app, you can use it. The renderer is really simple because the go library does all the computation of how to actually render the graph. It tries to be as close looking as possible as "sourcetree" algorithm. Not sure if this is clear explanation or not !
- voodootrucker 6y agoThis is cool, but it would be a lot more helpful to see how to run it on the git log directly in the readme, vs with JSON input. If that's possible, and you can brew/apt/choco install it, I'd use it for sure.
- Izkata 6y agoIsnt that the third section under "How to use" ?
- theamk 6y agoNote that this does not generate graphs from "linear history" -- the "linear history" means no merge commits / a single parent [0], and such graphs would be a straight lines. I think the "linear" here refers to the non-nested JSON structure? The better project title would be: "Generate a git graph structure from a flat list of git commits" BTW, a more traditional approach to graph generation uses Graphviz graph language (sometimes called "dot file") to visualize commits. It does not look as neat though, but there are more tooling there [1] [2] [0] https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/requiring-a-linear-commit-history https://docs.github.com/en/free-pro-team@latest/github/admin... [1] https://github.com/rpmiskin/git-graphviz https://github.com/rpmiskin/git-graphviz [2] https://return42.github.io/git2dot/slides/index.html#/3 https://return42.github.io/git2dot/slides/index.html#/3
- pokstad 6y agoNice. Mermaid JS has a similar visualization tool for commit graphs: https://mermaid-js.github.io/mermaid/#/?id=git-graph-exclamation-experimental https://mermaid-js.github.io/mermaid/#/?id=git-graph-exclama...
- cmwelsh 6y agoSo it makes a graph out of `git log`? If so, that’s pretty cool.
- alain_gilbert 6y agoThe goal of this library was to create a clone of sourcetree algorithm that you can use, the way you want, in your own software. You can actually try `git2graph -r` (inside a repository directory) and paste the output in the renderer http://alaingilbert.github.io/git2graph/ http://alaingilbert.github.io/git2graph/ , source of renderer -> https://github.com/alaingilbert/git2graph/blob/master/tools/renderer/index.html https://github.com/alaingilbert/git2graph/blob/master/tools/...