Skip to content

Commit 61f75e6

Browse files
committed
Upgrade github3.py to v1, click to v6, bump version to 0.7
1 parent b9aef99 commit 61f75e6

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

gitconsensus/repository.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def getPullRequest(self, number):
9393

9494
def isContributor(self, username):
9595
if not self.contributors:
96-
contributor_list = self.repository.iter_contributors()
96+
contributor_list = self.repository.contributors()
9797
self.contributors = [str(contributor) for contributor in contributor_list]
9898
return username in self.contributors
9999

@@ -106,14 +106,22 @@ def getConsensus(self):
106106
return Consensus(self.rules)
107107

108108
def setLabelColor(self, name, color):
109-
try:
109+
labels = self.get_labels()
110+
if name not in labels:
110111
self.repository.create_label(name, color)
111-
except:
112-
self.repository.update_label(name, color)
112+
elif color != labels[name].color:
113+
labels[name].update(name, color)
114+
115+
def get_labels(self):
116+
labels = {}
117+
for label in self.repository.labels():
118+
labels[label.name] = label
119+
return labels
113120

114121

115122
class PullRequest:
116123
labels = False
124+
117125
def __init__(self, repository, number):
118126
self.repository = repository
119127
self.consensus = repository.getConsensus()
@@ -148,7 +156,7 @@ def __init__(self, repository, number):
148156
continue
149157

150158
if 'collaborators_only' in self.repository.rules and self.repository.rules['collaborators_only']:
151-
if not isCollaborator(username):
159+
if not self.repository.isCollaborator(username):
152160
continue
153161

154162
if 'contributors_only' in self.repository.rules and self.repository.rules['contributors_only']:
@@ -195,7 +203,7 @@ def __init__(self, repository, number):
195203
if self.repository.isContributor(user['login']):
196204
self.contributors_abstain.append(user['login'])
197205

198-
files = self.pr.iter_files()
206+
files = self.pr.files()
199207
self.changes_consensus = False
200208
self.changes_license = False
201209
for changed_file in files:
@@ -205,7 +213,7 @@ def __init__(self, repository, number):
205213
self.changes_license = True
206214

207215
def hoursSinceLastCommit(self):
208-
commits = self.pr.iter_commits()
216+
commits = self.pr.commits()
209217

210218
for commit in commits:
211219
commit_date_string = commit._json_data['commit']['author']['date']
@@ -366,7 +374,7 @@ def addComment(self, comment_string):
366374
def getLabelList(self):
367375
if not self.labels:
368376
issue = self.getIssue()
369-
self.labels = [item.name for item in issue.labels]
377+
self.labels = [item.name for item in issue.labels()]
370378
return self.labels
371379

372380
def isBlocked(self):

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
long_description = open('README.md').read()
1414

1515

16-
version = '0.6.1'
16+
version = '0.7.0'
1717
setup(
1818

1919
name = 'gitconsensus',
@@ -44,8 +44,8 @@
4444
],
4545

4646
install_requires=[
47-
'click>=5.0,<6.0',
48-
'github3.py>=0.9.6,<0.10',
47+
'click>=6.0,<7.0',
48+
'github3.py>=1,<2',
4949
'PyYAML>=3.12,<3.13',
5050
'requests>=2.18.0,<2.19',
5151
],

0 commit comments

Comments
 (0)