Skip to content

Instantly share code, notes, and snippets.

@fujimura
Created October 20, 2022 14:20
Show Gist options
  • Save fujimura/532bd90fd2b66d139fea0396e0310024 to your computer and use it in GitHub Desktop.
Save fujimura/532bd90fd2b66d139fea0396e0310024 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import subprocess
import datetime
raw = (
subprocess.Popen(
'git log --pretty=" %at, %h" --reverse --after "2020/01/01" .rubocop_todo.yml',
shell=True,
stdout=subprocess.PIPE,
)
.stdout.read()
.decode()
)
x = []
y = []
lines = raw.splitlines()
lines.sort()
for l in lines:
unixtime, sha = l.split(",")
date = datetime.datetime.fromtimestamp(int(unixtime))
length = (
subprocess.Popen(
f"git cat-file -p {sha}:.rubocop_todo.yml | wc -l",
shell=True,
stdout=subprocess.PIPE,
)
.stdout.read()
.decode()
).strip()
x.append(date)
y.append(int(length))
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, ylim=(0, max(y) + 100))
plt.xticks(rotation=90)
ax.plot(x, y)
plt.tight_layout()
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment