# # 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 # # Paths may be absolute or relative to the smart_ide monorepo root (see conf_path_resolve.sh). # # Preconditions: PROJECT_CONFIG_PATH set and jq available. # Sets: IA_PROJECT_GIT_ROOT (exported), or empty if unresolved. # # shellcheck source=conf_path_resolve.sh source "$(dirname "${BASH_SOURCE[0]}")/conf_path_resolve.sh" 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_abs sp_abs r="$(jq -r '.deploy.repository_root // .deploy.git_work_tree // empty' "$PROJECT_CONFIG_PATH" 2>/dev/null || true)" r="${r//$'\r'/}" r_abs="$(ia_dev_resolve_path_from_conf "$PROJECT_CONFIG_PATH" "$r")" if [[ -n "$r_abs" && -d "$r_abs" ]]; then IA_PROJECT_GIT_ROOT="$r_abs" 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'/}" sp_abs="$(ia_dev_resolve_path_from_conf "$PROJECT_CONFIG_PATH" "$sp")" if [[ -n "$sp_abs" && "$sp_abs" != "null" ]]; then IA_PROJECT_GIT_ROOT="$(dirname "$sp_abs")" export IA_PROJECT_GIT_ROOT fi }