Skip to content

Commit

Permalink
merging PR #48
Browse files Browse the repository at this point in the history
#48

🙆‍♀️ PR passed with a vote of 2 for and 0 against, with a 
weighted total of 1.2 and a threshold of 1.0.

Vote record:
@Zidail: 1
@drindc24: 1
  • Loading branch information
chaosbot committed May 23, 2017
2 parents fda0309 + 3cf626f commit 9500e94
Showing 1 changed file with 18 additions and 32 deletions.
50 changes: 18 additions & 32 deletions chaos.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def install_requirements():

if __name__ == "__main__":
logging.info("starting up and entering event loop")

os.system("pkill chaos_server")
subprocess.Popen([sys.executable, "server.py"], cwd=join(THIS_DIR, "server"))

log.info("starting http server")
start_http_server()

while True:
log.info("looking for PRs")

Expand All @@ -87,35 +87,21 @@ def install_requirements():
pr_num = pr["number"]
logging.info("processing PR #%d", pr_num)

votes = gh.voting.get_votes(api, settings.URN, pr)

# is our PR approved or rejected?
vote_total = gh.voting.get_vote_sum(api, votes)
threshold = gh.voting.get_approval_threshold(api, settings.URN)
is_approved = vote_total >= threshold

if is_approved:
log.info("PR %d approved for merging!", pr_num)
try:
gh.prs.merge_pr(api, settings.URN, pr, votes, vote_total,
threshold)
# some error, like suddenly there's a merge conflict, or some
# new commits were introduced between findint this ready pr and
# merging it
except gh_exc.CouldntMerge:
log.info("couldn't merge PR %d for some reason, skipping",
pr_num)
gh.prs.label_pr(api, settings.URN, pr_num, ["can't merge"])
continue

gh.prs.label_pr(api, settings.URN, pr_num, ["accepted"])
needs_update = True

else:
log.info("PR %d rejected, closing", pr_num)
gh.comments.leave_reject_comment(api, settings.URN, pr_num)
gh.prs.label_pr(api, settings.URN, pr_num, ["rejected"])
gh.prs.close_pr(api, settings.URN, pr)
log.info("PR %d approved for merging!", pr_num)
try:
gh.prs.merge_pr(api, settings.URN, pr, votes, vote_total,
threshold)
# some error, like suddenly there's a merge conflict, or some
# new commits were introduced between findint this ready pr and
# merging it
except gh_exc.CouldntMerge:
log.info("couldn't merge PR %d for some reason, skipping",
pr_num)
gh.prs.label_pr(api, settings.URN, pr_num, ["can't merge"])
continue

gh.prs.label_pr(api, settings.URN, pr_num, ["accepted"])
needs_update = True


# we approved a PR, restart
Expand Down

0 comments on commit 9500e94

Please sign in to comment.