Skip to content

Commit

Permalink
Revert "merging PR #48"
Browse files Browse the repository at this point in the history
This reverts commit 9500e94, reversing
changes made to fda0309.

This is being reverted on a technicality, because the `votes` variable name was
not defined in chaos.py, it was killing the server.
  • Loading branch information
chaosbot committed May 23, 2017
1 parent 232feab commit f2cd29e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ See the source code for more details.

## Death Counter

Chaosbot has died 3 times. This counter is incremented whenever the trunk breaks
Chaosbot has died 4 times. This counter is incremented whenever the trunk breaks
and the server must be restarted manually.

## Server details
Expand Down
50 changes: 32 additions & 18 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,21 +87,35 @@ def install_requirements():
pr_num = pr["number"]
logging.info("processing PR #%d", pr_num)

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
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)


# we approved a PR, restart
Expand Down

0 comments on commit f2cd29e

Please sign in to comment.