Skip to content

Commit

Permalink
added some more error handling to contributors script. Also showing f…
Browse files Browse the repository at this point in the history
…ewer contributors per line in the table
  • Loading branch information
uchendui committed Oct 31, 2023
1 parent b3b12fb commit c134110
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/contributors/update_contributors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import collections
import json
import os

Expand Down Expand Up @@ -31,15 +32,17 @@ def main(_):
last_page = res.links.get('last', {}).get('url', None)

user_to_name_dict = dict()
users_from_api = []
name_to_user_dict = dict()
users_from_api = set()
user_full_names_from_api = set()

for node in data:
commit_info = node.get('commit', None)
commit_author_info = commit_info.get('author', None)
commit_commiter_info = commit_info.get('committer', None)
author_info = node.get('author', None)
committer_info = node.get('committer', None)
committer_login_info = committer_info.get('login', None)
committer_login_info = committer_info.get('login', None) if committer_info else None
user_full_name = None
username = None

Expand All @@ -53,13 +56,13 @@ def main(_):
elif committer_login_info:
username = committer_login_info['login']

assert user_full_name is not None, 'User full name should not be None'
assert username is not None, 'Username should not be None'
if user_full_name:
name_to_user_dict[user_full_name] = username if username else None
user_full_names_from_api.add(user_full_name)
if username:
user_to_name_dict[username] = user_full_name if user_full_name else None
users_from_api.add(username)

user_to_name_dict[username] = user_full_name
users_from_api.append(username)

users_from_api = set(users_from_api)
print('Users pulled from API: ', users_from_api)

with open(CONTRIBUTORS_FILE, 'r') as contrib_file:
Expand All @@ -78,7 +81,7 @@ def main(_):
users_from_api), 'All contributors in the .all-contributorsrc file should be pulled using the API'

new_contributor_logins = users_from_api - existing_contributor_logins_set
print('New contributors: ', new_contributor_logins)
print('New contributors: ', new_contributor_logins - EXCLUDED_USERS)

result = users_from_api - EXCLUDED_USERS

Expand All @@ -87,14 +90,15 @@ def main(_):
projectOwner=OWNER,
files=["contributors.qmd", "README.md"],
contributors=[dict(login=user,
name=user_to_name_dict[user],
name=user_to_name_dict[user] or user,
# If the user has no full name listed, use their username
avatar_url=f'https://avatars.githubusercontent.com/{user}',
profile=f'https://github.com/{user}',
contributions=['doc'], ) for
user in result],

repoType='github',
contributorsPerLine=7,
contributorsPerLine=5,
repoHost="https=//github.com",
commitConvention='angular',
skipCi=True,
Expand Down

0 comments on commit c134110

Please sign in to comment.