Skip to content

Commit bfbf598

Browse files
committed
Fix: Try different way of pulling from remote
1 parent c66a973 commit bfbf598

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

codeclash/agents/player.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ def __init__(
4747
"agent_stats": {}, # mapping round -> agent stats
4848
}
4949

50-
self.logger.info(f"Pulling latest changes from origin for {self.name}")
51-
assert_zero_exit_code(self.environment.execute("git pull origin"), logger=self.logger)
5250
if branch := config.get("branch_init"):
53-
self.logger.info(f"Fetching and checking out branch {branch}")
54-
assert_zero_exit_code(self.environment.execute(f"git fetch origin {branch}"), logger=self.logger)
51+
self.logger.info(f"Checking out branch {branch}")
5552
assert_zero_exit_code(self.environment.execute(f"git checkout {branch}"), logger=self.logger)
5653

5754
if self.push:

codeclash/games/game.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,19 @@ def get_environment(self, branch_name: str | None = None) -> DockerEnvironment:
198198
logger=self.logger,
199199
run_args=run_args,
200200
)
201+
202+
# Manually set URL with github token and git pull
203+
if github_token := os.getenv("GITHUB_TOKEN"):
204+
result = assert_zero_exit_code(environment.execute("git remote get-url origin"))
205+
current_url = result["output"].strip()
206+
if current_url.startswith("https://") and "@" not in current_url:
207+
new_url = current_url.replace("https://", f"https://{github_token}@")
208+
assert_zero_exit_code(environment.execute(f"git remote set-url origin {new_url} && git fetch origin"))
209+
else:
210+
self.logger.warning("Remote origin URL is not https://, won't be able to set token and pull.")
211+
else:
212+
self.logger.warning("GITHUB_TOKEN environment variable is not set, won't be able to pull.")
213+
201214
# Logger setting will likely not take effect for initial container creation logs
202215
environment.logger = get_logger("environment", emoji="🪴")
203216
# Ensure all future branches occur against branch

0 commit comments

Comments
 (0)