Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

retry if 422 Update is not a fast forward #134

Merged
merged 2 commits into from
Oct 2, 2017
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
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