From d12efc8ccf72d1774a57494aec1b7a87cb8659b1 Mon Sep 17 00:00:00 2001 From: didericis Date: Mon, 11 May 2026 19:44:11 -0400 Subject: [PATCH] refactor(docker): move provision_git into provision/git.py --- claude_bottle/backend/docker/backend.py | 22 ++---------- claude_bottle/backend/docker/provision/git.py | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 claude_bottle/backend/docker/provision/git.py diff --git a/claude_bottle/backend/docker/backend.py b/claude_bottle/backend/docker/backend.py index d6a417d..affd39f 100644 --- a/claude_bottle/backend/docker/backend.py +++ b/claude_bottle/backend/docker/backend.py @@ -34,6 +34,7 @@ from .pipelock import ( DockerPipelockProxy, pipelock_proxy_url, ) +from .provision import git as _git from .provision import prompt as _prompt from .provision import skills as _skills from .provision import ssh as _ssh @@ -320,27 +321,8 @@ class DockerBottleBackend(BottleBackend): _ssh.provision_ssh(plan, target) def provision_git(self, plan: BottlePlan, target: str) -> None: - """If --cwd was set and the host cwd has a .git directory, copy - it into /home/node/workspace/.git and fix ownership. No-op - otherwise.""" assert isinstance(plan, DockerBottlePlan) - if not (plan.spec.copy_cwd and Path(plan.spec.user_cwd, ".git").is_dir()): - return - container = target - info(f"copying {plan.spec.user_cwd}/.git -> {container}:/home/node/workspace/.git") - subprocess.run( - ["docker", "cp", f"{plan.spec.user_cwd}/.git", f"{container}:/home/node/workspace/.git"], - stdout=subprocess.DEVNULL, - check=True, - ) - subprocess.run( - [ - "docker", "exec", "-u", "0", container, - "chown", "-R", "node:node", "/home/node/workspace/.git", - ], - stdout=subprocess.DEVNULL, - check=True, - ) + _git.provision_git(plan, target) # --- Cleanup --- diff --git a/claude_bottle/backend/docker/provision/git.py b/claude_bottle/backend/docker/provision/git.py new file mode 100644 index 0000000..3007fac --- /dev/null +++ b/claude_bottle/backend/docker/provision/git.py @@ -0,0 +1,36 @@ +"""Copy the host cwd's .git directory into a running Docker bottle. + +Only fires when `--cwd` was passed AND the host cwd actually has a +.git. The container-side path is fixed at /home/node/workspace/.git; +ownership is reset to node so the agent can run git commands.""" + +from __future__ import annotations + +import subprocess +from pathlib import Path + +from ....log import info +from ..bottle_plan import DockerBottlePlan + + +def provision_git(plan: DockerBottlePlan, target: str) -> None: + """If --cwd was set and the host cwd has a .git directory, copy + it into /home/node/workspace/.git and fix ownership. No-op + otherwise.""" + if not (plan.spec.copy_cwd and Path(plan.spec.user_cwd, ".git").is_dir()): + return + container = target + info(f"copying {plan.spec.user_cwd}/.git -> {container}:/home/node/workspace/.git") + subprocess.run( + ["docker", "cp", f"{plan.spec.user_cwd}/.git", f"{container}:/home/node/workspace/.git"], + stdout=subprocess.DEVNULL, + check=True, + ) + subprocess.run( + [ + "docker", "exec", "-u", "0", container, + "chown", "-R", "node:node", "/home/node/workspace/.git", + ], + stdout=subprocess.DEVNULL, + check=True, + )