|
| 1 | +# pylint: disable=broad-exception-caught |
1 | 2 | """This file contains the main() and other functions needed to get contributor information from the organization or repository""" |
2 | 3 |
|
| 4 | +import sys |
3 | 5 | import env |
4 | 6 | import auth |
5 | 7 | import contributor_stats |
@@ -123,39 +125,47 @@ def get_contributors( |
123 | 125 | """ |
124 | 126 | all_repo_contributors = repo.contributors() |
125 | 127 | contributors = [] |
126 | | - for user in all_repo_contributors: |
127 | | - # Ignore contributors with [bot] in their name |
128 | | - if "[bot]" in user.login: |
129 | | - continue |
130 | | - |
131 | | - # Check if user has commits in the date range |
132 | | - if start_date and end_date: |
133 | | - user_commits = repo.commits( |
134 | | - author=user.login, since=start_date, until=end_date |
135 | | - ) |
136 | | - |
137 | | - # If the user has no commits in the date range, skip them |
138 | | - try: |
139 | | - next(user_commits) |
140 | | - except StopIteration: |
| 128 | + try: |
| 129 | + for user in all_repo_contributors: |
| 130 | + # Ignore contributors with [bot] in their name |
| 131 | + if "[bot]" in user.login: |
141 | 132 | continue |
142 | 133 |
|
143 | | - # Store the contributor information in a ContributorStats object |
144 | | - if start_date and end_date: |
145 | | - commit_url = f"https://github.com/{repo.full_name}/commits?author={user.login}&since={start_date}&until={end_date}" |
146 | | - else: |
147 | | - commit_url = ( |
148 | | - f"https://github.com/{repo.full_name}/commits?author={user.login}" |
| 134 | + # Check if user has commits in the date range |
| 135 | + if start_date and end_date: |
| 136 | + user_commits = repo.commits( |
| 137 | + author=user.login, since=start_date, until=end_date |
| 138 | + ) |
| 139 | + |
| 140 | + # If the user has no commits in the date range, skip them |
| 141 | + try: |
| 142 | + next(user_commits) |
| 143 | + except StopIteration: |
| 144 | + continue |
| 145 | + |
| 146 | + # Store the contributor information in a ContributorStats object |
| 147 | + if start_date and end_date: |
| 148 | + commit_url = f"https://github.com/{repo.full_name}/commits?author={user.login}&since={start_date}&until={end_date}" |
| 149 | + else: |
| 150 | + commit_url = ( |
| 151 | + f"https://github.com/{repo.full_name}/commits?author={user.login}" |
| 152 | + ) |
| 153 | + contributor = contributor_stats.ContributorStats( |
| 154 | + user.login, |
| 155 | + False, |
| 156 | + user.avatar_url, |
| 157 | + user.contributions_count, |
| 158 | + commit_url, |
| 159 | + "", |
149 | 160 | ) |
150 | | - contributor = contributor_stats.ContributorStats( |
151 | | - user.login, |
152 | | - False, |
153 | | - user.avatar_url, |
154 | | - user.contributions_count, |
155 | | - commit_url, |
156 | | - "", |
| 161 | + contributors.append(contributor) |
| 162 | + except Exception as e: |
| 163 | + print("Error getting contributors for repository: " + repo.full_name) |
| 164 | + print( |
| 165 | + "No more repositories will be processed. Please delete the (empty?) repository and try again." |
157 | 166 | ) |
158 | | - contributors.append(contributor) |
| 167 | + print(e) |
| 168 | + sys.exit(1) |
159 | 169 |
|
160 | 170 | return contributors |
161 | 171 |
|
|
0 commit comments