Skip to content

Commit

Permalink
bots: Handle 'fork_collab' GitHub permissions failure
Browse files Browse the repository at this point in the history
The bots may not have permission to set maintainer_can_modify
on certain pull requests. Retry without it when we get that failure.
  • Loading branch information
stefwalter committed Jul 12, 2017
1 parent 57ce59b commit f5ae3ce
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bots/task/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,13 @@ def pull(branch, issue=None, **kwargs):
else:
data["title"] = kwargs["title"]

pull = api.post("pulls", data)
pull = api.post("pulls", data, accept=[ 422 ])

# If we were refused to grant maintainer_can_modify, then try without
if "errors" in pull:
if pull["errors"][0]["field"] == "fork_collab":
data["maintainer_can_modify"] = False
pull = api.post("pulls", data)

# Update the issue if it is a dict
if issue:
Expand Down

0 comments on commit f5ae3ce

Please sign in to comment.