Skip to content

Instantly share code, notes, and snippets.

@hydroid7
Last active April 22, 2019 19:50
Show Gist options
  • Save hydroid7/dca1ae304b49e9231b8326bd5ae1edd8 to your computer and use it in GitHub Desktop.
Save hydroid7/dca1ae304b49e9231b8326bd5ae1edd8 to your computer and use it in GitHub Desktop.
Git stats with Julia. It uses the awesome package UnicodePlots.jl to draw some stats about the Git repository where this file is executed.
using UnicodePlots
const points = 20
function command(from, to)
start = "HEAD" * "^"^from
last = "HEAD" * "^"^to
`git diff --numstat $start $last`
end
data = zeros(points, 3)
for i = collect(1:points)
res = split(read(command(i - 1, i), String), "\t")
if size(res)[1] > 3
data[i, :] = [i parse(Float64, res[1]) parse(Float64, res[2])]
end
end
p = barplot(["Add", "Delete"],
[sum(data[:, 2]), sum(data[:, 3])],
title = "Changed Lines over the last $points commits.")
println(p)
p = lineplot(data[:, 1], data[:, 2], title = "LoC", name = "Addition", xlabel = "Commits", ylabel = "LoC")
lineplot!(p, data[:, 1], data[:, 3], color = :blue, name = "Deletion")
println(p)
### Usage
cd your/git/repo
julia git-stats.jl
### Result (it looks better in the terminal ;-)
Changed Lines over the last 20 commits.
┌ ┐
Add ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 26533.0
Delete ┤■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 23654.0
└ ┘
LoC
┌────────────────────────────────────────┐
20000 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ Addition
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ Deletion
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
LoC │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡆⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀│
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⢣⠀│
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡎⢱⠀⠀⠀⠀⠀⠀⠀⠀⡜⠈⡆│
│⠀⠀⠀⠀⠀⠀⠀⡠⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢸⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢸│
│⠀⠀⠀⠀⠀⢀⠞⠁⢣⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⠁⠈⡆⠀⠀⠀⠀⠀⠀⢰⠁⢀⠇│
│⠀⠀⠀⢀⠔⠁⠀⠀⠸⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⡇⠀⠀⠀⠀⠀⠀⢸⢀⡎⠀│
│⠀⠀⡠⠋⠀⠀⠀⠀⠀⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⢸⠀⠀⠀⠀⠀⠀⣇⠎⠀⠀│
0 │⣠⣊⣀⣀⣀⣀⣀⣀⣀⣸⣀⣀⣀⣀⣀⣀⣀⣀⣀⣔⣑⣢⣤⣒⣑⣤⣇⣀⣀⣸⣀⣀⣀⣀⣀⣀⡏⠀⠀⠀│
└────────────────────────────────────────┘
0 20
Commits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment