fix: refactor: lib/env.sh — split into a defined-surface shared lib; entrypoints own context-specific paths (#674)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/pr/smoke-init Pipeline was successful

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude 2026-04-11 13:21:30 +00:00
parent 3d7c27f6c6
commit 6589c761ba
6 changed files with 86 additions and 25 deletions

View file

@ -103,22 +103,11 @@ if [ -n "$FORGE_REPO" ]; then
export FORGE_REPO_OWNER="${FORGE_REPO%%/*}"
fi
# Derive PROJECT_REPO_ROOT if not explicitly set
if [ -z "${PROJECT_REPO_ROOT:-}" ] && [ -n "${PROJECT_NAME:-}" ]; then
export PROJECT_REPO_ROOT="/home/${USER}/${PROJECT_NAME}"
fi
# Derive OPS_REPO_ROOT if not explicitly set
if [ -z "${OPS_REPO_ROOT:-}" ] && [ -n "${PROJECT_NAME:-}" ]; then
export OPS_REPO_ROOT="/home/${USER}/${PROJECT_NAME}-ops"
fi
# Inside the container, always derive repo paths from PROJECT_NAME — the TOML
# carries host-perspective paths that do not exist in the container filesystem.
if [ "${DISINTO_CONTAINER:-}" = "1" ] && [ -n "${PROJECT_NAME:-}" ]; then
export PROJECT_REPO_ROOT="/home/agent/repos/${PROJECT_NAME}"
export OPS_REPO_ROOT="/home/agent/repos/${PROJECT_NAME}-ops"
fi
# PROJECT_REPO_ROOT and OPS_REPO_ROOT: no fallback derivation from USER/HOME.
# These must be set by the entrypoint (container) or the TOML (host CLI).
# Inside the container, the entrypoint exports the correct paths before agent
# scripts source env.sh; the TOML's host-perspective paths are skipped by the
# DISINTO_CONTAINER guard above.
# Derive FORGE_OPS_REPO if not explicitly set
if [ -z "${FORGE_OPS_REPO:-}" ] && [ -n "${FORGE_REPO:-}" ]; then