Skip to content

Commit

Permalink
Auto merge of barosl#134 - Eh2406:master, r=Manishearth
Browse files Browse the repository at this point in the history
retry if 422 Update is not a fast forward

As @kennytm suggested in rust-lang/rust#43535 This is a quick fix to try and suppress the [intermittent 422 errors.](servo#24)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/homu/134)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Oct 2, 2017
2 parents 4424aed + 878e02e commit 387c218
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion homu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import time


def github_set_ref(repo, ref, sha, *, force=False, auto_create=True):
def github_set_ref(repo, ref, sha, *, force=False, auto_create=True, retry=1):
url = repo._build_url('git', 'refs', ref, base_url=repo._api)
data = {'sha': sha, 'force': force}

Expand All @@ -20,6 +20,14 @@ def github_set_ref(repo, ref, sha, *, force=False, auto_create=True):
return repo.create_ref('refs/' + ref, sha)
except github3.models.GitHubError:
raise e
elif e.code == 422 and retry > 0:
time.sleep(5)
return github_set_ref(repo,
ref,
sha,
force=force,
auto_create=auto_create,
retry=retry - 1)
else:
raise

Expand Down

0 comments on commit 387c218

Please sign in to comment.