za3karia commited on
Commit
93c25c8
·
verified ·
1 Parent(s): 9da74bc

Update functions.py

Browse files
Files changed (1) hide show
  1. functions.py +30 -0
functions.py CHANGED
@@ -90,6 +90,36 @@ def extract_commit_summary(commit_data):
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,branches, updated_token=None):
95
  """
 
90
  }
91
 
92
  return commit_summary
93
+
94
+ # Adjusted function to get commit files and stats
95
+ def get_commit_files_and_stats(commit_url, updated_token=None):
96
+ headers = get_headers(updated_token)
97
+ response = requests.get(commit_url, headers=headers)
98
+ commit_data = response.json()
99
+
100
+ files_info = []
101
+ if 'files' in commit_data:
102
+ for file in commit_data['files']:
103
+ files_info.append({
104
+ 'filename': file['filename'],
105
+ 'status': file['status'],
106
+ 'additions': file['additions'],
107
+ 'deletions': file['deletions'],
108
+ 'changes': file['changes'],
109
+ 'patch': file.get('patch') # Use get to avoid KeyError if 'patch' does not exist
110
+ })
111
+
112
+ stats_info = commit_data.get('stats', {})
113
+
114
+ author_name = commit_data['commit']['author']['name']
115
+ commit_message = commit_data['commit']['message']
116
+
117
+ return {
118
+ 'author_name': author_name,
119
+ 'commit_message': commit_message,
120
+ 'files_info': files_info,
121
+ 'stats_info': stats_info
122
+ }
123
  # Function to fetch commits by a contributor in a given period
124
  def get_contributor_commits(repo_name, contributor, period,branches, updated_token=None):
125
  """