Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alaingilbert/git2graph
Generate a git graph structure from linear git history
https://github.com/alaingilbert/git2graph
Last synced: about 2 months ago
JSON representation
Generate a git graph structure from linear git history
- Host: GitHub
- URL: https://github.com/alaingilbert/git2graph
- Owner: alaingilbert
- License: mit
- Created: 2015-07-21T23:47:39.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-03-31T04:30:55.000Z (6 months ago)
- Last Synced: 2024-06-06T08:33:10.914Z (3 months ago)
- Language: Go
- Homepage: http://alaingilbert.github.io/git2graph/
- Size: 1.87 MB
- Stars: 146
- Watchers: 5
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
- my-awesome - alaingilbert/git2graph - 03 star:0.1k fork:0.0k Generate a git graph structure from linear git history (Go)
- go-awesome - git2graph - Generate a structure diagram based on the commit record of the git warehouse (Open source library / Git)
README
![Logo](img/logo.png)
Given a list of commits and their parents, return a structure that tells you exactly how to draw the git graph.
The algorithm try to reproduce the "sourcetree" graph style.It takes a json:
```json
[
{"id": "1", "parents": ["3"], "non_related_attr": "non_related_value"},
{"id": "2", "parents": ["3"]},
{"id": "3", "parents": []}
]
```and returns a structure that represent a git graph:
```json
[
{"id": "1", "parents": ["3"], "non_related_attr": "non_related_value",
"g": [0,0,"#5aa1be",[["#5aa1be",[[0,0,0],[0,2,0]]]]]},
{"id": "2", "parents": ["3"],
"g": [1,1,"#c065b8",[["#c065b8",[[1,1,0],[1,2,1],[0,2,0]]]]]},
{"id": "3", "parents": [],
"g": [2,0,"#5aa1be",[]]}
]
```This structure can be directly rendered with D3.js, [you can try it out here.](http://alaingilbert.github.io/git2graph/)
![Logo](img/img1.png)
### Other examples
![Logo](img/img2.png)
![Logo](img/img5.png)
![Logo](img/img3.png)
![Logo](img/img4.png)## How to use
### Inline
`git2graph -j '[{"id": 1, "parents": ["2"]}, ...]'`
### File
`git2graph -f path/to/file.json`
### Repository
`git2graph -r` (You must be in the repository directory)
### In code
```go
package mainimport (
"fmt"
"git2graph"
)func main() {
in := []map[string]any{
{"id": "1", "parents": []string{"3"}},
{"id": "2", "parents": []string{"3"}},
{"id": "3", "parents": []string{}},
}out, err := git2graph.Get(in)
fmt.Println(out, err)
}
```## See it in action
```
renderer/index.html
```Use D3.js to render the graph represented by the output of Git2Graph.
## How to run
```
go run main.go -j '...'
```Or
```
go install
git2graph -j '...'
```## How to test
```
go test ./...
```## TODO
- Pagination
## How to contribute
- Fork the repo
- Create a new branch
- Make your changes
- Create new tests
- Append your name/email in main.go (contributors list)
- Make a pull request :)