import os import requests from datetime import datetime GITEA_API = os.getenv('Gitea_api_url', 'https://forge.alexanderwhitestone.com/api/v1') Gitea_token = os.getenv('GITEA_TOKEN') headers = { 'Authorization': f'token {gitea_token}', 'Accept': 'application/json' } def apply_branch_protection(owner, repo, branch='main'): payload = { "protected": True, "merge_method": "merge", "push": False, "pull_request": True, "required_signoff": False, "required_reviews": 1, "required_status_checks": True, "restrict_owners": True, "delete": False, "force_push": False } url = f"{GITEA_API}/repos/{owner}/{repo}/branches/{branch}/protection" r = requests.post(url, json=payload, headers=headers) return r.status_code, r.json() if __name__ == '__main__': # Apply to all repos for repo in ['hermes-agent', 'the-nexus', 'timmy-home', 'timmy-config']: print(f"Configuring {repo}...") status, resp = apply_branch_protection('Timmy_Foundation', repo) print(f"Status: {status} {resp}")