From dfe5aba8803e8939422bdbcab18ae09739cfa461 Mon Sep 17 00:00:00 2001 From: katie <32645020+katherine-hough@users.noreply.github.com> Date: Sat, 14 Jun 2025 13:11:00 -0400 Subject: [PATCH] * Modified the `fetch_patch` function to handle responses with more than one page of data. --- main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 62323f0..7a278aa 100644 --- a/main.py +++ b/main.py @@ -24,11 +24,16 @@ def fetch_patch(): 'X-GitHub-Api-Version': '2022-11-28', 'Authorization':f'Bearer {TOKEN}' } - git_request = git_session.get( - f'{api_url}/repos/{repo}/pulls/{pr}/files', - headers=headers - ) - return git_request.json() + # Fetch the first page + response = git_session.get( + f"{api_url}/repos/{repo}/pulls/{pr}/files", headers=headers + ) + files = response.json() + # Follow 'next' links to fetch the remaining pages + while 'next' in response.links: + response = git_session.get(response.links['next']['url'], headers=headers) + files.extend(response.json()) + return files def parse_patch_data(patch_data): '''Takes the patch data and returns a dictionary of files and the lines'''