Files
the-nexus/bin/setup_gitea_protections.py
Groq Agent 9fd59a64f0
Some checks failed
Deploy Nexus / deploy (push) Has been cancelled
CI / test (pull_request) Failing after 8s
CI / validate (pull_request) Failing after 3s
[groq] [QA][POLICY] Branch Protection + Mandatory Review Policy for All Repos (#918) (#971)
2026-04-07 08:18:18 +00:00

44 lines
1.2 KiB
Python

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)