Skip to content

Commit 8bee08a

Browse files
authored
Merge pull request #2 from haasonsaas/fix/github-timeline-fallback
fix: tolerate github timeline api absence
2 parents 0dda616 + bf2fde0 commit 8bee08a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/provenance/github_resolver.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,12 +604,23 @@ def _collect_timeline(self, repo_full_name: str, pr_number: int, pr=None) -> dic
604604
return cached[1]
605605

606606
data = {"events": [], "summary": {"force_pushes": 0, "reopens": 0, "merge_events": 0, "review_requests": 0, "review_dismissals": 0}}
607+
timeline_items: list = []
607608
try:
608609
target_pr = pr or self._get_pull(repo_full_name, pr_number)
609610
if not target_pr:
610611
self._timeline_cache[key] = (now + self._cache_ttl, data)
611612
return data
612-
timeline_items = target_pr.get_timeline()
613+
get_timeline = getattr(target_pr, "get_timeline", None)
614+
if callable(get_timeline):
615+
try:
616+
timeline_items = list(get_timeline())
617+
except GithubException:
618+
timeline_items = []
619+
else:
620+
try:
621+
timeline_items = list(target_pr.get_issue_events())
622+
except GithubException:
623+
timeline_items = []
613624
except GithubException:
614625
timeline_items = []
615626

0 commit comments

Comments
 (0)