Skip to content

Commit

Permalink
Refactor file retrieval to use GitHub library instead of requests
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed Nov 6, 2024
1 parent 3d8ba73 commit 11402ce
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions github_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import sys

import github
import requests
import yaml

from lib.galaxy_social import galaxy_social
Expand Down Expand Up @@ -64,12 +63,14 @@ def get_files(self):
for file in self.pr.get_files():
file_path = file.filename
if file_path.endswith(".md"):
response = requests.get(file.raw_url)
if response.status_code == 200:
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with open(file_path, "w") as f:
f.write(response.text)
files_to_process.append(file_path)
head_branch = self.pr.head
pr_content = head_branch.repo.get_contents(
file_path, ref=head_branch.ref
).decoded_content.decode()
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with open(file_path, "w") as f:
f.write(pr_content)
files_to_process.append(file_path)

return files_to_process

Expand Down

0 comments on commit 11402ce

Please sign in to comment.