@@ -93,7 +93,7 @@ def getPullRequest(self, number):
93
93
94
94
def isContributor (self , username ):
95
95
if not self .contributors :
96
- contributor_list = self .repository .iter_contributors ()
96
+ contributor_list = self .repository .contributors ()
97
97
self .contributors = [str (contributor ) for contributor in contributor_list ]
98
98
return username in self .contributors
99
99
@@ -106,14 +106,22 @@ def getConsensus(self):
106
106
return Consensus (self .rules )
107
107
108
108
def setLabelColor (self , name , color ):
109
- try :
109
+ labels = self .get_labels ()
110
+ if name not in labels :
110
111
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
113
120
114
121
115
122
class PullRequest :
116
123
labels = False
124
+
117
125
def __init__ (self , repository , number ):
118
126
self .repository = repository
119
127
self .consensus = repository .getConsensus ()
@@ -148,7 +156,7 @@ def __init__(self, repository, number):
148
156
continue
149
157
150
158
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 ):
152
160
continue
153
161
154
162
if 'contributors_only' in self .repository .rules and self .repository .rules ['contributors_only' ]:
@@ -195,7 +203,7 @@ def __init__(self, repository, number):
195
203
if self .repository .isContributor (user ['login' ]):
196
204
self .contributors_abstain .append (user ['login' ])
197
205
198
- files = self .pr .iter_files ()
206
+ files = self .pr .files ()
199
207
self .changes_consensus = False
200
208
self .changes_license = False
201
209
for changed_file in files :
@@ -205,7 +213,7 @@ def __init__(self, repository, number):
205
213
self .changes_license = True
206
214
207
215
def hoursSinceLastCommit (self ):
208
- commits = self .pr .iter_commits ()
216
+ commits = self .pr .commits ()
209
217
210
218
for commit in commits :
211
219
commit_date_string = commit ._json_data ['commit' ]['author' ]['date' ]
@@ -366,7 +374,7 @@ def addComment(self, comment_string):
366
374
def getLabelList (self ):
367
375
if not self .labels :
368
376
issue = self .getIssue ()
369
- self .labels = [item .name for item in issue .labels ]
377
+ self .labels = [item .name for item in issue .labels () ]
370
378
return self .labels
371
379
372
380
def isBlocked (self ):
0 commit comments