@@ -30,6 +30,7 @@ class GHorg: # pylint: disable=too-many-instance-attributes
30
30
current_teams : dict [Team .Team , dict ] = field (default_factory = dict )
31
31
configured_teams : dict [str , dict | None ] = field (default_factory = dict )
32
32
current_repos : dict [Repository .Repository , dict [Team .Team , str ]] = field (default_factory = dict )
33
+ archived_repos : list [Repository .Repository ] = field (default_factory = list )
33
34
34
35
# --------------------------------------------------------------------------
35
36
# Helper functions
@@ -307,12 +308,21 @@ def get_members_without_team(self) -> None:
307
308
# --------------------------------------------------------------------------
308
309
# Repos
309
310
# --------------------------------------------------------------------------
310
- def _get_current_repos_and_perms (self ) -> None :
311
+ def _get_current_repos_and_perms (self , ignore_archived : bool ) -> None :
311
312
"""Get all repos, their current teams and their permissions"""
312
313
for repo in list (self .org .get_repos ()):
313
- self .current_repos [repo ] = {}
314
- for team in list (repo .get_teams ()):
315
- self .current_repos [repo ][team ] = team .permission
314
+ # Check if repo is archived. If so, ignore it, if user requested so
315
+ if ignore_archived and repo .archived :
316
+ logging .debug (
317
+ "Ignoring %s as it is archived and user requested to ignore such repos" ,
318
+ repo .name ,
319
+ )
320
+ self .archived_repos .append (repo )
321
+ continue
322
+ else :
323
+ self .current_repos [repo ] = {}
324
+ for team in list (repo .get_teams ()):
325
+ self .current_repos [repo ][team ] = team .permission
316
326
317
327
def _create_perms_changelist_for_teams (
318
328
self ,
@@ -349,12 +359,12 @@ def _create_perms_changelist_for_teams(
349
359
350
360
return team_changelist
351
361
352
- def sync_repo_permissions (self , dry : bool = False ) -> None :
362
+ def sync_repo_permissions (self , dry : bool = False , ignore_archived : bool = False ) -> None :
353
363
"""Synchronise the repository permissions of all teams"""
354
364
logging .debug ("Starting to sync repo/team permissions" )
355
365
356
366
# Get all repos and their current permissions from GitHub
357
- self ._get_current_repos_and_perms ()
367
+ self ._get_current_repos_and_perms (ignore_archived )
358
368
359
369
# Find differences between configured permissions for a team's repo and the current state
360
370
for team , repos in self ._create_perms_changelist_for_teams ().items ():
0 commit comments