Skip to content

Commit

Permalink
Use Repository content API to get consensus file
Browse files Browse the repository at this point in the history
  • Loading branch information
tedivm committed Feb 21, 2018
1 parent 70afc55 commit 544b854
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gitconsensus/repository.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import base64
import datetime
import github3
import json
Expand Down Expand Up @@ -28,7 +29,7 @@
"""

consensus_url_template = "https://raw.githubusercontent.com/%s/%s/master/.gitconsensus.yaml"
consensus_url_template = "https://api.github.com/repos/%s/%s/contents/.gitconsensus.yaml"


def githubApiRequest(url, client):
Expand All @@ -50,7 +51,8 @@ def __init__(self, user, repository, client):
res = githubApiRequest(consensusurl, self.client)
self.rules = False
if res.status_code == 200:
self.rules = yaml.load(res.text)
ruleresults = res.json()
self.rules = yaml.load(base64.b64decode(ruleresults['content']).decode('utf-8'))
# support older versions by converting from day to hours.
if 'version' not in self.rules or self.rules['version'] < 2:
if 'mergedelay' in self.rules and self.rules['mergedelay']:
Expand Down

0 comments on commit 544b854

Please sign in to comment.