@@ -165,28 +165,42 @@ class GitHubBackend:
165
165
'livestream' : 'AO: Livestream' ,
166
166
}
167
167
168
- def __init__ (self , repo_name : str ) -> None :
168
+ def __init__ (
169
+ self ,
170
+ repo_name : str ,
171
+ include_area_owners : bool = False ,
172
+ include_components : bool = False ,
173
+ ) -> None :
169
174
self .github = github .Github (get_github_credential ())
170
175
self .repo = self .github .get_repo (repo_name )
171
176
self .milestones : Dict [str , github .Milestone .Milestone ] = {
172
177
x .title : x for x in self .repo .get_milestones ()
173
178
}
174
179
180
+ self .include_area_owners = include_area_owners
181
+ self .include_components = include_components
182
+
175
183
labels : Dict [str , github .Label .Label ] = {
176
184
x .name : x for x in self .repo .get_labels ()
177
185
}
178
186
179
187
try :
180
- self ._component_label_mapping = {
181
- k : [labels [x ] for x in v ]
182
- for k , v in self .COMPONENT_LABEL_MAPPING .items ()
183
- }
188
+ if include_components :
189
+ self ._component_label_mapping = {
190
+ k : [labels [x ] for x in v ]
191
+ for k , v in self .COMPONENT_LABEL_MAPPING .items ()
192
+ }
193
+ else :
194
+ self ._component_label_mapping = {}
184
195
self ._component_priority_mapping = {
185
196
k : labels [v ] for k , v in self .COMPONENT_PRIORITY_MAPPING .items ()
186
197
}
187
- self ._area_owner_mapping = {
188
- k : labels [v ] for k , v in self .AREA_OWNER_MAPPING .items ()
189
- }
198
+ if include_area_owners :
199
+ self ._area_owner_mapping = {
200
+ k : labels [v ] for k , v in self .AREA_OWNER_MAPPING .items ()
201
+ }
202
+ else :
203
+ self ._area_owner_mapping = {}
190
204
except KeyError as e :
191
205
raise ValueError (
192
206
f"Label { e } does not exist within { repo_name !r} " ,
@@ -229,8 +243,10 @@ def get_or_create_milestone(self, title: str) -> github.Milestone.Milestone:
229
243
230
244
def labels (self , ticket : Ticket ) -> List [github .Label .Label ]:
231
245
labels = [self ._component_priority_mapping [ticket .priority ]]
232
- labels += self ._component_label_mapping [ticket .component ]
233
- labels .append (self ._area_owner_mapping [ticket .area_owner ])
246
+ if self .include_components :
247
+ labels += self ._component_label_mapping [ticket .component ]
248
+ if self .include_area_owners :
249
+ labels .append (self ._area_owner_mapping [ticket .area_owner ])
234
250
return labels
235
251
236
252
def submit (self , ticket : Ticket ) -> int :
0 commit comments