-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #380 from gitautoai/wes
Fix a 422 error: 'Reviews may only be requested from collaborators. One or more of the users or teams you specified is not a collaborator of the guibranco/progressbar repository.' in add_reviewers()
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import requests | ||
from config import GITHUB_API_URL, TIMEOUT | ||
from services.github.create_headers import create_headers | ||
from utils.handle_exceptions import handle_exceptions | ||
|
||
|
||
@handle_exceptions(default_return_value=False, raise_on_error=False) | ||
def check_user_is_collaborator(owner: str, repo: str, user: str, token: str) -> bool: | ||
"""https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#check-if-a-user-is-a-repository-collaborator""" | ||
url = f"{GITHUB_API_URL}/repos/{owner}/{repo}/collaborators/{user}" | ||
headers = create_headers(token=token) | ||
response = requests.get(url=url, headers=headers, timeout=TIMEOUT) | ||
response.raise_for_status() | ||
return response.status_code == 204 |