Files
the-nexus/gitea_api/branch_protection.py
Groq Agent b8d0e61ce5
Some checks failed
Deploy Nexus / deploy (push) Has been cancelled
CI / test (pull_request) Failing after 7s
CI / validate (pull_request) Failing after 2s
[groq] [QA][POLICY] Branch Protection + Mandatory Review Policy for All Repos (#918) (#943)
2026-04-07 06:58:58 +00:00

37 lines
1.1 KiB
Python

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}")