Merge pull request #512 from AIOSAI/work/drone
feat(drone): DPLAN-0163 Finding 8: set AIPASS_BRANCH_NAME on dispatch
This commit is contained in:
@@ -113,7 +113,10 @@ def execute_branch_command(
|
||||
cmd_args += [command] + list(args or [])
|
||||
|
||||
# Pass caller's CWD so target branches can detect who invoked them
|
||||
caller_env = {"AIPASS_CALLER_CWD": str(Path.cwd())}
|
||||
caller_env = {
|
||||
"AIPASS_CALLER_CWD": str(Path.cwd()),
|
||||
"AIPASS_BRANCH_NAME": branch_name,
|
||||
}
|
||||
|
||||
# Detect caller branch name from passport.json, fall back to env var
|
||||
# (dispatched agents set AIPASS_BRANCH_NAME which survives cd)
|
||||
|
||||
@@ -142,6 +142,20 @@ class TestExecuteBranchCommand:
|
||||
assert "AIPASS_CALLER_CWD" in env
|
||||
assert env["AIPASS_CALLER_CWD"] == str(Path.cwd())
|
||||
|
||||
@patch("aipass.drone.apps.handlers.router_handler.execute_command")
|
||||
def test_sets_aipass_branch_name_to_target(self, mock_exec, branch_dir: Path):
|
||||
"""AIPASS_BRANCH_NAME is set to the target branch name on dispatch."""
|
||||
mock_exec.return_value = CommandResult(stdout="", stderr="", exit_code=0, branch="", command="")
|
||||
|
||||
execute_branch_command(
|
||||
branch_path=str(branch_dir),
|
||||
branch_name="fakebranch",
|
||||
command="test",
|
||||
)
|
||||
|
||||
env = mock_exec.call_args.kwargs.get("env", {})
|
||||
assert env["AIPASS_BRANCH_NAME"] == "fakebranch"
|
||||
|
||||
@patch("aipass.drone.apps.handlers.router_handler.execute_command")
|
||||
def test_timeout_propagated_to_executor(self, mock_exec, branch_dir: Path):
|
||||
"""Timeout value is forwarded to execute_command."""
|
||||
|
||||
Reference in New Issue
Block a user