Spaces:
Sleeping
Sleeping
File size: 701 Bytes
62dbc85 3866642 62dbc85 3866642 62dbc85 3866642 62dbc85 64ba99a 62dbc85 3866642 62dbc85 3866642 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import requests
def fetch_pr_diff(owner, repo, pr_number, token=None):
headers = {
"Accept": "application/vnd.github.v3.diff"
}
if token:
headers["Authorization"] = f"token {token}"
url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}"
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.text
elif response.status_code == 404:
return "Error: PR not found. Check the repo and PR number."
elif response.status_code == 401:
return "Error: Unauthorized. Check your GitHub token."
else:
return f"Error: Could not fetch PR. Status code: {response.status_code}"
|