aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/line_count/collect-history.py
blob: e5e8b42fdc2b75693391569d26b9b26dc2e9c7ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python

import subprocess
import datetime

def daterange(start, end):
  for n in range(int((end - start).days)):
    yield start + datetime.timedelta(n)

start_date = datetime.date(2017, 3, 26)
end_date = datetime.date(2017, 3, 29)

for dt in daterange(start_date, end_date):
  dmy = dt.strftime('%Y-%m-%d')
  sha1 = subprocess.check_output(['git', 'rev-list', '-n', '1',
                                  '--before=%s' % dmy,
                                  'master']).strip()
  subprocess.check_call(['git', 'checkout', sha1])
  subprocess.check_call(['git', 'submodule', 'update'])
  subprocess.check_call(['git', 'clean', '-f', '-x', '-d'])
  subprocess.check_call(['cloc', '--vcs=git', '--by-file', '--yaml', '--out=../count/%s.yaml' % dmy, '.'])