-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitFunctions.py
More file actions
55 lines (45 loc) · 1.72 KB
/
gitFunctions.py
File metadata and controls
55 lines (45 loc) · 1.72 KB
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
from pydriller import RepositoryMining
import csv
import time
def initialise():
file_shared_by = {}
committer_set = set()
# db = GraphDatabase("http://localhost:7474", username="neo4j",
# password="n3o4j")
# committer_email = db.labels.create("CommitterEmail")
for commit in RepositoryMining(
'/Users/kirtanasuresh/Documents/WebDev/myapp/che',
only_in_branch="master").traverse_commits():
# prevent duplicate node creation
if commit.committer.email == "noreply@github.com":
email = commit.author.email
# print(commit.author.name)
else:
email = commit.committer.email
# name = commit.committer.name
if email not in committer_set:
committer_set.add(email)
# committer_email.add(db.nodes.create(name=email))
for mod in commit.modifications:
if mod.filename in file_shared_by:
file_shared_by[mod.filename].add(email)
else:
com = set()
com.add(email)
file_shared_by[mod.filename] = com
# file_shared_by['pink'] = {'purple', 'magenta'}
# file_shared_by['orange'] = {'red', 'yellow'}
print("mapping complete")
with open('filemap.csv', 'w') as f:
w = csv.writer(f, delimiter=',')
w.writerow(["filename","committers"])
for key, values in file_shared_by.items():
values = ' '.join(values)
w.writerow([key, values])
def main():
start_time = time.time()
initialise()
print("--- %s seconds to map the file ---" % (time.time() -
start_time))
if __name__ == '__main__':
main()