diff --git a/bin/setup_gitea_protections.py b/bin/setup_gitea_protections.py new file mode 100644 index 0000000..63809ec --- /dev/null +++ b/bin/setup_gitea_protections.py @@ -0,0 +1,43 @@ +import os +import requests +from typing import Dict, List + +GITEA_API = os.getenv("GITEA_API_URL", "https://forge.alexanderwhitestone.com/api/v1") +GITEA_TOKEN = os.getenv("GITEA_TOKEN") +REPOS = [ + "hermes-agent", + "the-nexus", + "timmy-home", + "timmy-config", +] + +BRANCH_PROTECTION = { + "required_pull_request_reviews": True, + "required_status_checks": True, + "required_signatures": False, + "required_linear_history": False, + "allow_force_push": False, + "allow_deletions": False, + "required_approvals": 1, + "dismiss_stale_reviews": True, + "restrictions": { + "users": ["@perplexity"], + "teams": [] + } +} + +def apply_protection(repo: str): + url = f"{GITEA_API}/repos/Timmy_Foundation/{repo}/branches/main/protection" + headers = { + "Authorization": f"token {GITEA_TOKEN}", + "Content-Type": "application/json" + } + response = requests.post(url, json=BRANCH_PROTECTION, headers=headers) + if response.status_code == 200: + print(f"✅ Protection applied to {repo}/main") + else: + print(f"❌ Failed to apply protection to {repo}/main: {response.text}") + +if __name__ == "__main__": + for repo in REPOS: + apply_protection(repo)