@@ -83,6 +83,9 @@ class BcrValidationResult(Enum):
8383
8484GITHUB_REPO_RE = re .compile (r"^(https://github.com/|github:)([^/]+/[^/]+)$" )
8585
86+ # Global cache for GitHub user IDs
87+ GITHUB_USER_ID_CACHE = {}
88+
8689
8790def print_collapsed_group (name ):
8891 print ("\n \n --- {0}\n \n " .format (name ))
@@ -210,22 +213,27 @@ def check_github_url(repo_path, source_url):
210213
211214def get_github_user_id (github_username ):
212215 """
213- Get the GitHub user ID for a given GitHub username.
216+ Get the GitHub user ID for a given GitHub username, with caching .
214217
215218 Args:
216219 github_username: The GitHub username to look up.
217220
218221 Returns:
219222 The GitHub user ID if found, otherwise None.
220223 """
224+ if github_username in GITHUB_USER_ID_CACHE :
225+ return GITHUB_USER_ID_CACHE [github_username ]
226+
221227 url = f"https://api.github.com/users/{ github_username } "
222228 headers = {}
223229 github_token = os .getenv ("GITHUB_TOKEN" )
224230 if github_token :
225231 headers ["Authorization" ] = f"token { github_token } "
226232 response = requests .get (url , headers = headers )
227233 if response .status_code == 200 :
228- return response .json ().get ("id" )
234+ user_id = response .json ().get ("id" )
235+ GITHUB_USER_ID_CACHE [github_username ] = user_id
236+ return user_id
229237 return None
230238
231239
0 commit comments