-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommitMessage.py
73 lines (55 loc) · 1.71 KB
/
commitMessage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 30 22:01:27 2018
@author: gaurav
"""
import pandas as pd
import xlsxwriter
'''pd.read_json('https://api.github.com/repos/hmrc/tai/commits')'''
def commitMessages(url):
json = None
try:
json = pd.read_json(url)
except:
json = None
messages = []
isPreviousYear = False
if(json is not None or json.empty):
return (messages, True)
for key, value in json['commit'].items():
t = pd.to_datetime(value['author']['date'])
messages.append((value['author']['date'], value['author']['name'], value['message']))
if(t.year != 2018):
isPreviousYear = True
break;
return (messages, isPreviousYear)
def writeToExcel(app, msgs):
row = 1
col = 0
workbook = xlsxwriter.Workbook('commits/' + app + '.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write(0, 0, 'date')
worksheet.write(0, 1, 'name')
worksheet.write(0, 2, 'comments')
worksheet.write(0, 3, 'month')
for msg in msgs:
d,n,c = msg
worksheet.write(row, col, d)
worksheet.write(row, col + 1, n)
worksheet.write(row, col + 2, c)
worksheet.write(row, col + 3, pd.to_datetime(d).month)
row += 1
workbook.close()
def commitsForYear(app, appUrl):
(messages, isPreviousYear) = commitMessages(appUrl)
c = 1;
while(not isPreviousYear):
c = c+1
u = appUrl + '?page=' + str(c)
print(u)
(m, i) = commitMessages(u)
messages = messages + m
isPreviousYear = i
writeToExcel(app, messages)
return messages