4646from otterdog .models .repo_workflow_settings import RepositoryWorkflowSettings
4747from otterdog .models .repository import Repository
4848from otterdog .models .team import Team
49- from otterdog .utils import IndentingPrinter , associate_by_key , debug_times , jsonnet_evaluate_file
49+ from otterdog .utils import IndentingPrinter , associate_by_key , debug_times , is_set_and_present , jsonnet_evaluate_file
5050
5151if TYPE_CHECKING :
5252 from collections .abc import AsyncIterator , Callable , Iterator
@@ -672,7 +672,7 @@ async def _process_single_repo(
672672 repo_name : str ,
673673 jsonnet_config : JsonnetConfig ,
674674 teams : dict [str , Any ],
675- repo_permissions : dict [str , list [dict [str , Any ]]],
675+ repo_permissions : dict [str , list [dict [str , Any ]]] | None ,
676676 app_installations : dict [str , str ],
677677) -> tuple [str , Repository ]:
678678 rest_api = gh_client .rest_api
@@ -683,8 +683,11 @@ async def _process_single_repo(
683683
684684 github_repo_workflow_data = await rest_api .repo .get_workflow_settings (github_id , repo_name )
685685 repo .workflows = RepositoryWorkflowSettings .from_provider_data (github_id , github_repo_workflow_data )
686- repo_permission = repo_permissions .get (repo_name , [])
687- repo .set_team_permissions ({entry ["name" ]: entry ["permission" ] for entry in repo_permission })
686+ if repo_permissions is not None :
687+ repo_permission = repo_permissions .get (repo_name , [])
688+ repo .set_team_permissions ({entry ["name" ]: entry ["permission" ] for entry in repo_permission })
689+ else :
690+ repo .unset_team_permissions ()
688691
689692 if jsonnet_config .default_branch_protection_rule_config is not None :
690693 # get branch protection rules of the repo
@@ -803,7 +806,12 @@ async def _load_repos_from_provider(
803806 repo_names = fnmatch .filter (repo_names , repo_filter )
804807
805808 teams = {str (team ["id" ]): f"{ github_id } /{ team ['slug' ]} " for team in await provider .get_org_teams (github_id )}
806- repo_permissions = build_repo_permissions (await provider .get_team_permissions (github_id ))
809+
810+ default_org_repo = Repository .from_model_data (jsonnet_config .default_repo_config )
811+ if is_set_and_present (default_org_repo .team_permissions ):
812+ repo_permissions = build_repo_permissions (await provider .get_team_permissions (github_id ))
813+ else :
814+ repo_permissions = None
807815
808816 # limit the number of repos that are processed concurrently to avoid hitting secondary rate limits
809817 sem = asyncio .Semaphore (50 if concurrency is None else concurrency )
0 commit comments