# # Resolve the application git repository root from projects//conf.json. # Used by ia_dev deploy wrappers (pousse, branch-align, change-to-all-branches, deploy-by-script-to). # # Priority: # 1. deploy.repository_root (preferred) # 2. deploy.git_work_tree (alias) # 3. dirname(deploy.secrets_path) — legacy; breaks if secrets live outside the repo tree # # Preconditions: PROJECT_CONFIG_PATH set and jq available. # Sets: IA_PROJECT_GIT_ROOT (exported), or empty if unresolved. # ia_dev_resolve_project_git_root() { IA_PROJECT_GIT_ROOT="" export IA_PROJECT_GIT_ROOT if [[ -z "${PROJECT_CONFIG_PATH:-}" || ! -f "$PROJECT_CONFIG_PATH" ]]; then return 0 fi if ! command -v jq >/dev/null 2>&1; then return 0 fi local r sp r="$(jq -r '.deploy.repository_root // .deploy.git_work_tree // empty' "$PROJECT_CONFIG_PATH" 2>/dev/null || true)" r="${r//$'\r'/}" if [[ -n "$r" && "$r" != "null" && -d "$r" ]]; then IA_PROJECT_GIT_ROOT="$r" export IA_PROJECT_GIT_ROOT return 0 fi sp="$(jq -r '.deploy.secrets_path // empty' "$PROJECT_CONFIG_PATH" 2>/dev/null || true)" sp="${sp//$'\r'/}" if [[ -n "$sp" && "$sp" != "null" ]]; then IA_PROJECT_GIT_ROOT="$(dirname "$sp")" export IA_PROJECT_GIT_ROOT fi }