Skip to content

Commit

Permalink
feat(auto-readme/regen_readme_in_batch): pick testing branch if it ex…
Browse files Browse the repository at this point in the history
…ists
  • Loading branch information
Psycojoker committed Mar 30, 2024
1 parent c2bf5b3 commit fd1d250
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tools/readme_generator/regen_readme_in_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shlex
import asyncio
import tempfile
import requests

from make_readme import generate_READMEs
from pathlib import Path
Expand Down Expand Up @@ -44,6 +45,19 @@ async def regen_readme(repository, branch):
print(f"{repository} -> branch '{branch}'")
print("=" * len(f"{repository} -> branch '{branch}'"))

branches = requests.get(
f"https://api.github.com/repos/{repository}/branches",
headers={
"Authorization": f"Bearer {token}",
"X-GitHub-Api-Version": "2022-11-28",
"Accept": "application/vnd.github+json",
}
).json()

branches = {x["name"] for x in branches}
if "testing" in branches:
branch = "testing"

with tempfile.TemporaryDirectory() as folder:
await git(["clone", f"https://{login}:{token}@github.com/{repository}", "--single-branch", "--branch", branch, folder])

Expand Down

0 comments on commit fd1d250

Please sign in to comment.