Last active
October 3, 2016 08:07
-
-
Save klausbrunner/0652a060239828c07d2ede6f233a9099 to your computer and use it in GitHub Desktop.
Track a repo manifest's project count over time using GitPython. Prints simple "datetime count" table.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from git import Repo | |
import datetime as dt | |
import xml.etree.ElementTree as ET | |
repo = Repo('/home/klaus/stats/manifests') | |
target_file = 'manifest.xml' | |
assert not repo.bare | |
manifest_cts = list(repo.iter_commits(paths=target_file)) | |
for ct in reversed(manifest_cts): | |
date = dt.datetime.utcfromtimestamp(ct.committed_date).isoformat() | |
# print(ct.hexsha, date, ct.summary) | |
blob = ct.tree / target_file | |
root = ET.fromstring(blob.data_stream.read()) | |
proj_count = len(root.findall('./project')) | |
print(date, proj_count) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment