Spaces:
Sleeping
Sleeping
Update functions.py
Browse files- functions.py +26 -2
functions.py
CHANGED
@@ -67,6 +67,29 @@ def get_start_date(period):
|
|
67 |
else:
|
68 |
raise ValueError("Invalid period specified")
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
# Function to fetch commits by a contributor in a given period
|
71 |
def get_contributor_commits(repo_name, contributor, period, updated_token=None):
|
72 |
"""
|
@@ -106,5 +129,6 @@ def get_contributor_commits(repo_name, contributor, period, updated_token=None):
|
|
106 |
commits.extend(branch_commits)
|
107 |
except requests.exceptions.RequestException as e:
|
108 |
print(f"Failed to fetch commits: {e}")
|
109 |
-
|
110 |
-
return
|
|
|
|
67 |
else:
|
68 |
raise ValueError("Invalid period specified")
|
69 |
|
70 |
+
|
71 |
+
def extract_commit_summary(commit_data):
|
72 |
+
# Assuming commit_data is a dict containing commit information as fetched from GitHub's API
|
73 |
+
commit_details = commit_data.get('commit', {})
|
74 |
+
author_info = commit_details.get('author', {})
|
75 |
+
files_info = commit_data.get('files', []) # Assuming this is where you get files information
|
76 |
+
|
77 |
+
commit_summary = {
|
78 |
+
'message': commit_details.get('message', ''),
|
79 |
+
'author': author_info.get('name', ''),
|
80 |
+
'date': author_info.get('date', ''), # Include commit date
|
81 |
+
'file_patches': [
|
82 |
+
{'filename': file.get('filename', ''), 'patch': file.get('patch', '')}
|
83 |
+
for file in files_info if 'patch' in file
|
84 |
+
],
|
85 |
+
'stats': {
|
86 |
+
'additions': commit_details.get('stats', {}).get('additions', 0),
|
87 |
+
'deletions': commit_details.get('stats', {}).get('deletions', 0),
|
88 |
+
'total': commit_details.get('stats', {}).get('total', 0)
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
return commit_summary
|
93 |
# Function to fetch commits by a contributor in a given period
|
94 |
def get_contributor_commits(repo_name, contributor, period, updated_token=None):
|
95 |
"""
|
|
|
129 |
commits.extend(branch_commits)
|
130 |
except requests.exceptions.RequestException as e:
|
131 |
print(f"Failed to fetch commits: {e}")
|
132 |
+
summarized_commits = [extract_commit_summary(commit) for commit in commits]
|
133 |
+
return summarized_commits
|
134 |
+
|