Git Visualization
25 oct 14 - MeetupJS Singapore
Joshua Koo
Joshua Koo
@blurspline
Zopim / Zendesk
Git Visualization
Git Visualization
(in JS of course, duh)
3ource
a brief history...
![](https://media.slid.es/uploads/zz85/images/578293/893080_547574911948860_866008139_o.jpg)
SuperHappyDevHouse
3ource
3ource
#ph41L for s0URC3
3ource
Three Source
3ource
Tree Source or Source Tree
maybe, Tree Sauce?
Git
![](https://media.slid.es/uploads/zz85/images/578305/Screenshot_2014-08-25_10.59.26.png)
![](https://media.slid.es/uploads/zz85/images/578307/Strips-_Old-650-finalfinal1.jpg)
![](https://media.slid.es/uploads/zz85/images/578311/git-flux.png)
![](https://media.slid.es/uploads/zz85/images/578314/Screen-shot-2009-12-24-at-11.32.03.png)
![](https://media.slid.es/uploads/zz85/images/578319/git_commit.png)
rgc() {
git commit -m"`curl -s http://whatthecommit.com/index.txt`"
}
For more: http://www.commitlogsfromlastnight.com/
Our CTO has discovered an incredible way of making developers read his commit messages. You won’t even believe how he did it!
![](https://media.slid.es/uploads/zz85/images/578332/Screenshot_2014-08-25_11.11.40.png)
![](https://media.slid.es/uploads/zz85/images/578335/Screenshot_2014-08-25_11.18.51.png)
http://www.commitstrip.com/en/2014/08/07/
Visualize
![](https://media.slid.es/uploads/zz85/images/578367/Screenshot_2014-08-25_11.25.17.png)
Mission:
how can we present git history in a way its useful and appealing?
![](https://media.slid.es/uploads/zz85/images/578401/Screenshot_2014-08-25_11.39.05.png)
![](https://media.slid.es/uploads/zz85/images/578411/Screenshot_2014-08-25_11.43.20.png)
![](https://media.slid.es/uploads/zz85/images/578415/Screenshot_2014-08-25_11.43.30.png)
![](https://media.slid.es/uploads/zz85/images/578414/Screenshot_2014-08-25_11.43.34.png)
![](https://media.slid.es/uploads/zz85/images/578422/Screenshot_2014-08-25_09.52.59.png)
Twitter Code Swarm
![](https://media.slid.es/uploads/zz85/images/578426/maxresdefault.jpg)
Code!
Goals
- Build a Git Log viewer that runs in the browser
- Animate directory structure of repository over time
Challenges
- How do we get git data in JS to the browser?
- How do we render huge amount of logs?
- How do we visualize a git folder structure automatically?
- How do we build a nice UI?
Git Data in JS
- Github API
- Pipe Data from Command Line
- node.js Bindings
- Git in JS
Data Needed
- Git logs
- author
- message
- date
- hash
- Git tree diffs
- filenames
- add
- delete
- modified
Pipe from Process
var exec = require('child_process').exec;
exec(GIT_LOG_CMD, {
cwd: cwd,
maxBuffer: 1024 * 1024 * 200 // abuse memory up to 200MB ;P
}, function (error, stdout, stderr) {
// handle and parse stdout here
})
);
fs.writeFileSync(OUTPUT_JSON_FILE, json, 'utf8');
Custom Git Log format
git log --raw -m --pretty=format:"bla" --encoding=UTF-8
Where "bla" = pretty format placeholders
![](https://media.slid.es/uploads/zz85/images/578473/Screenshot_2014-08-25_12.25.38.png)
git log --help
Pretty Git Log Viewer
![](https://media.slid.es/uploads/zz85/images/578481/Screenshot_2014-06-15_20.36.49.png)
Strategy
- Build the graph paths in memory
- Graph is rendered on Canvas
- Row Rendering is done with a virtual view port
Directory Rendering
- Get directory structure at commit #####
- layout algorithm
- WebGL?
Git Tree
git ls-tree -r COMMIT
Cache directory filenames
Force Directed Layouts
Nodes with simulated forces
Minilistic event dispatcher
npm install do.js
var Do = require('do.js');
var onFire = new Do();
onFire.do(something)
onFire.fire('bla');
Finally...
![](https://media.slid.es/uploads/zz85/images/578935/6a00d8341d3df553ef0133ecdfd99d970b.jpg)
One Big Hack but a WIP
suggestions, ideas, comments
Shameless Plug:
![](https://media.slid.es/uploads/zz85/images/578921/logo-text.png)
Thank you
Git Visualization 25 oct 14 - MeetupJS Singapore Joshua Koo
Git & Visualization
By Joshua Koo
Git & Visualization
slides for presentation for SingaporeJS talk.js meetup http://www.meetup.com/Singapore-JS/events/197757042/
- 5,536