Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_gitea_issues function: Add issue type, content check #76

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions 5_open_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,33 @@ def get_gitea_issues(gitea_token, gitea_org):
gitea_issues = []
page = 1
while True:
url = (
f"{GITEA_API_ENDPOINT}/repos/issues/search?state=open&owner={gitea_org}&page={page}"
f"&limit=1000&type=issues&token={gitea_token}"
)
try:
repos_resp = requests.get(f"{GITEA_API_ENDPOINT}/repos/issues/search?state=open&owner={gitea_org}&page=\
{page}&limit=1000&token={gitea_token}", timeout=10)
repos_resp.raise_for_status()
response = requests.get(url, timeout=10)
response.raise_for_status()

if not response.content:
logging.error("Received an empty response from the server.")
break

issues_list = response.json()
if not issues_list:
logging.info("No more issues returned by the server.")
break

gitea_issues.extend(issues_list)

except requests.exceptions.RequestException as e:
logging.error("Gitea issues: an error occurred while trying to get Gitea issues for %s: %s", gitea_org, e)
logging.error(f"Gitea issues: an error occurred while trying to get Gitea issues for {gitea_org}: {e}")
break

try:
issues_dict = json.loads(repos_resp.content.decode())
for issue in issues_dict:
gitea_issues.append(issue)
except json.JSONDecodeError as e:
logging.error("Gitea issues: an error occurred while trying to decode JSON: %s", e)
link_header = response.headers.get("Link")
if not link_header or "rel=\"next\"" not in link_header:
break

link_header = repos_resp.headers.get("Link")
if link_header is None or "rel=\"next\"" not in link_header:
break
page += 1

return gitea_issues
Expand Down