@@ -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
115122class 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 ):
0 commit comments