setup: calcul du chemin relatif robuste aux symlinks/submodules
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user