Skip to content

Commit ee5b5ce

Browse files
committed
Added GitAnalyzer
1 parent c745f4f commit ee5b5ce

File tree

7 files changed

+69
-0
lines changed

7 files changed

+69
-0
lines changed

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/VisualizingCode.iml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FileStatisticsMiner/GitAnalyzer.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pydriller import Repository
2+
3+
4+
def analyze_repository(path):
5+
"""
6+
Analyzes a git repository and returns a tuple containing the combinations of files modified and path combinations
7+
:param path: the git repository URL
8+
:return: a tuple containing path combinations and file modifications.
9+
"""
10+
11+
combinations = []
12+
modifications = []
13+
14+
for commit in Repository(path).traverse_commits():
15+
paths = []
16+
for file in commit.modified_files:
17+
paths.append(file.new_path)
18+
record = {
19+
'path': file.new_path,
20+
'commit': commit.hash,
21+
'author': commit.author.name,
22+
'lines_added': file.added_lines,
23+
'lines_deleted': file.deleted_lines,
24+
}
25+
modifications.append(record)
26+
combinations.append({'hash': commit.hash, 'paths': paths}
27+
)
28+
29+
return combinations, modifications

0 commit comments

Comments
 (0)