MCPcopy Index your code
hub / github.com/CodeClash-ai/CodeClash / main

Function main

scripts/push_log_to_gh.py:21–95  ·  view source on GitHub ↗
(cc_folder: Path)

Source from the content-addressed store, hash-verified

19
20
21def main(cc_folder: Path):
22 folder_contents = [f.name for f in list(cc_folder.iterdir())]
23 assert "metadata.json" in folder_contents, "No metadata.json found"
24 assert "players" in folder_contents, "No players/ folder found"
25
26 arena = cc_folder.name.split(".", 2)[1]
27
28 # Clone GitHub repository if it doesn't exist
29 if arena not in os.listdir():
30 clone_cmd = f"git clone git@github.com:{GH_ORG}/{arena}.git"
31 subprocess.run(clone_cmd, shell=True, check=True)
32
33 # Get existing remote branches
34 remote_branches = (
35 subprocess.run(
36 "git branch -r",
37 shell=True,
38 check=True,
39 capture_output=True,
40 cwd=arena,
41 )
42 .stdout.decode("utf-8")
43 .splitlines()
44 )
45 remote_branches = [b.split("/")[-1] for b in remote_branches if "PvpTournament" in b]
46
47 # Identify players
48 with open(cc_folder / "metadata.json") as f:
49 metadata = json.load(f)
50 players = [x["name"] for x in metadata["config"]["players"]]
51
52 # Detect default branch name
53 default_branch = (
54 subprocess.run(
55 "git symbolic-ref refs/remotes/origin/HEAD",
56 shell=True,
57 check=True,
58 capture_output=True,
59 cwd=arena,
60 )
61 .stdout.decode("utf-8")
62 .strip()
63 .split("/")[-1]
64 )
65 print(f"Default branch detected: {default_branch}")
66
67 # Push diffs for each player
68 for player in players:
69 player_log_folder = cc_folder / "players" / player
70 branch_name = f"{cc_folder.name}.{player}"
71 if branch_name in remote_branches:
72 print(f"Branch {branch_name} already exists, skipping...")
73 continue
74 subprocess.run(
75 f"git checkout {default_branch}; git branch {branch_name} -D; git checkout -b {branch_name}",
76 shell=True,
77 check=True,
78 cwd=arena,

Callers 1

push_log_to_gh.pyFile · 0.70

Calls 2

remove_binariesFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected