**Motivations:** - secrets_path dirname is not a stable git root when secrets move to ia_dev **Correctifs:** - lib/project_git_root_from_conf.sh: repository_root || git_work_tree || dirname(secrets_path) **Evolutions:** - lecoffreio conf.json: deploy.repository_root, deploy.hooks.phases scaffold - pousse, branch-align, change-to-all-branches, deploy-by-script-to use resolver **Pages affectées:** - lib/project_git_root_from_conf.sh, deploy/*.sh, projects/lecoffreio/conf.json
37 lines
1.2 KiB
Bash
37 lines
1.2 KiB
Bash
#
|
|
# Resolve the application git repository root from projects/<id>/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
|
|
}
|