Skip to content

Commit

Permalink
Remove potential infinote loop
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Jul 13, 2021
1 parent b5217a5 commit d389cc6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions conbench/entities/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ def get_github_commit(repository, sha):
if parent in commits:
return commit
else:
# this is a pull request, find the parent of the first commit
# This is a pull request, find the parent of the first commit.
# TODO: This will fail if the pull request has more than 50 commits.
# It will also give up if it can't find the parent aftter 50 tries
# (which could happen for a really old pull request).
parent = commit["parent"]
while True:
for _ in range(50):
other = github.get_commit(name, parent)
if other["parent"] in commits:
commit["parent"] = other["parent"]
Expand Down Expand Up @@ -102,6 +105,9 @@ def get_commits(self, name, sha):
return self.test_commits

commits = []

# Grabs the last 1000 commits to the main branch. TODO: If the pull
# request is old, the parent may not be in the last 1000 commits.
for branch in ["master", "main"]:
url = f"{GITHUB}/repos/{name}/commits?sha={branch}&per_page=100"
response = self._get_response(url)
Expand Down

0 comments on commit d389cc6

Please sign in to comment.