From d24544db658c640940c335d92f7aa20106a645b6 Mon Sep 17 00:00:00 2001 From: bachir Date: Mon, 7 Sep 2026 11:28:18 +0200 Subject: [PATCH] setup: calcul du chemin relatif robuste aux symlinks/submodules --- setup | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/setup b/setup index 7a45e59..dea29a6 100755 --- a/setup +++ b/setup @@ -14,18 +14,26 @@ set -euo pipefail SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # Dépôt à configurer : le superprojet si on est un submodule, sinon le dépôt courant. +# On utilise les chemins rapportés par git (cohérents, insensibles aux symlinks). SUPER=$(git -C "$SCRIPTS_DIR" rev-parse --show-superproject-working-tree 2>/dev/null || true) if [ -n "$SUPER" ]; then TARGET="$SUPER" + SUBTOP=$(git -C "$SCRIPTS_DIR" rev-parse --show-toplevel) + REL="${SUBTOP#"$TARGET"/}" # ex: gitploy else TARGET=$(git -C "$SCRIPTS_DIR" rev-parse --show-toplevel) + REL="" # outil à la racine du dépôt fi -# Chemin de l'outil relatif au dépôt cible (pour un alias portable). -REL="${SCRIPTS_DIR#"$TARGET"/}" +# Chemin de l'outil, portable, résolu au runtime via show-toplevel. +if [ -n "$REL" ]; then + TOOLPATH="\$(git rev-parse --show-toplevel)/$REL" +else + TOOLPATH="\$(git rev-parse --show-toplevel)" +fi -git -C "$TARGET" config alias.deploy "!\"\$(git rev-parse --show-toplevel)/$REL/git-deploy\"" -git -C "$TARGET" config alias.hotfix "!\"\$(git rev-parse --show-toplevel)/$REL/git-hotfix\"" +git -C "$TARGET" config alias.deploy "!\"$TOOLPATH/git-deploy\"" +git -C "$TARGET" config alias.hotfix "!\"$TOOLPATH/git-hotfix\"" # Branche de dev par défaut si non définie. git -C "$TARGET" config deploy.source >/dev/null 2>&1 || git -C "$TARGET" config deploy.source master