From 3cbb9a7903da66f9a87e5fc03ceb1ce9c00754fb Mon Sep 17 00:00:00 2001 From: Iain Dillingham Date: Tue, 16 Sep 2025 11:57:05 +0100 Subject: [PATCH] Exclude a repo from configuration management This adds the ability to exclude a (core) repo from configuration management, and uses that ability to exclude opensafely-core/ethelred. Why? Team PIN have been experimenting with trunk-based development as well as GitHub flow workflows, and have decided to adopt a workflow that sits between the two: [Ship / Show / Ask][1]. To adopt this workflow, they would like to allow PRs to be merged to the mainline branch without approval; and *possibly* to remove branch protection rules from the mainline branch. [1]: https://martinfowler.com/articles/ship-show-ask.html --- manage-github.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/manage-github.py b/manage-github.py index 994062d..9971a78 100755 --- a/manage-github.py +++ b/manage-github.py @@ -36,6 +36,7 @@ "required_approving_review_count": 1, } +EXCLUDED_REPOS = ["opensafely-core/ethelred"] def convert_protection(protection): """Convert protection read format to the right format. @@ -191,10 +192,12 @@ def input_with_timeout(prompt, timeout=5.0): return None -def manage_code(org, repo_policy=None, branch_policy=None): +def manage_code(org, repo_policy=None, branch_policy=None, excluded_repos=None): """Ensure that all opensafe-core repos have the correct configuration.""" code = client.GithubTeam(org) - for repo in code.repos.values(): + excluded_repos = set() if excluded_repos is None else set(excluded_repos) + repos = [repo for name, repo in code.repos.items() if name not in excluded_repos] + for repo in repos: print(repo.full_name) if repo_policy: yield from configure_repo(repo, **repo_policy) @@ -264,7 +267,7 @@ def main(argv=sys.argv[1:]): # analyse changes needed changes = itertools.chain( manage_studies(studies, REPO_POLICY, STUDY_BRANCH_POLICY), - manage_code(core, REPO_POLICY, CODE_BRANCH_POLICY), + manage_code(core, REPO_POLICY, CODE_BRANCH_POLICY, EXCLUDED_REPOS), ) for change in changes: