diff --git a/scripts/agents/documents_bureautiques_agent.sh b/scripts/agents/documents_bureautiques_agent.sh index f6fc469..d10704b 100755 --- a/scripts/agents/documents_bureautiques_agent.sh +++ b/scripts/agents/documents_bureautiques_agent.sh @@ -10,7 +10,7 @@ echo "# Agent Documents bureautiques" > "$SUMMARY_FILE" echo >> "$SUMMARY_FILE" pushd "$TARGET_DIR" >/dev/null -docsx=$(git ls-files '*.docx' 2>/dev/null || true) +docsx=$(git -C "$TARGET_DIR" ls-files '*.docx' 2>/dev/null || true) if [[ -z "$docsx" ]]; then echo "- Aucun fichier .docx détecté." >> "$SUMMARY_FILE" else diff --git a/scripts/agents/donnees_csv_agent.sh b/scripts/agents/donnees_csv_agent.sh index 9467409..b70eb17 100755 --- a/scripts/agents/donnees_csv_agent.sh +++ b/scripts/agents/donnees_csv_agent.sh @@ -10,7 +10,7 @@ echo "# Agent Données CSV" > "$SUMMARY_FILE" echo >> "$SUMMARY_FILE" pushd "$TARGET_DIR" >/dev/null -csvs=$(git ls-files '*.csv' 2>/dev/null || true) +csvs=$(git -C "$TARGET_DIR" ls-files '*.csv' 2>/dev/null || true) if [[ -z "$csvs" ]]; then echo "- Aucun CSV détecté dans le dépôt." >> "$SUMMARY_FILE" else diff --git a/scripts/agents/lang_detect.sh b/scripts/agents/lang_detect.sh index cd2d313..04028e6 100755 --- a/scripts/agents/lang_detect.sh +++ b/scripts/agents/lang_detect.sh @@ -12,7 +12,7 @@ export HAS_NODE=0 HAS_TYPESCRIPT=0 HAS_GO=0 HAS_RUST=0 HAS_PYTHON=0 HAS_SHELL_BA # Node / TypeScript if has_file package.json; then HAS_NODE=1; fi -if has_file tsconfig.json || git ls-files '*.ts' | grep -q . 2>/dev/null; then HAS_TYPESCRIPT=1; fi +if has_file tsconfig.json || git -C "${TARGET_DIR:-.}" ls-files '*.ts' | grep -q . 2>/dev/null; then HAS_TYPESCRIPT=1; fi # Go if has_file go.mod || has_file go.work; then HAS_GO=1; fi @@ -21,13 +21,13 @@ if has_file go.mod || has_file go.work; then HAS_GO=1; fi if has_file Cargo.toml; then HAS_RUST=1; fi # Python -if has_file pyproject.toml || has_file requirements.txt || git ls-files '*.py' | grep -q . 2>/dev/null; then HAS_PYTHON=1; fi +if has_file pyproject.toml || has_file requirements.txt || git -C "${TARGET_DIR:-.}" ls-files '*.py' | grep -q . 2>/dev/null; then HAS_PYTHON=1; fi # Shell (bash) -if git ls-files '*.sh' | grep -q . 2>/dev/null; then HAS_SHELL_BASH=1; fi +if git -C "${TARGET_DIR:-.}" ls-files '*.sh' | grep -q . 2>/dev/null; then HAS_SHELL_BASH=1; fi # PowerShell (pwsh) -if git ls-files '*.ps1' | grep -q . 2>/dev/null; then HAS_SHELL_PWSH=1; fi +if git -C "${TARGET_DIR:-.}" ls-files '*.ps1' | grep -q . 2>/dev/null; then HAS_SHELL_PWSH=1; fi # Exposer aussi l'état des outils lorsqu’ils existent export HAS_NPM=0 HAS_NPX=0 HAS_GO_BIN=0 HAS_CARGO=0 HAS_PYTHON_BIN=0 HAS_PIP=0 HAS_SHELLCHECK=0 HAS_PWSH=0 diff --git a/scripts/agents/quality_tech.sh b/scripts/agents/quality_tech.sh index a365f4d..f77f994 100755 --- a/scripts/agents/quality_tech.sh +++ b/scripts/agents/quality_tech.sh @@ -75,7 +75,7 @@ if [[ "$HAS_PYTHON" -eq 1 ]]; then fi if [[ "$HAS_SHELL_BASH" -eq 1 ]]; then if [[ "$HAS_SHELLCHECK" -eq 1 ]]; then - (git ls-files '*.sh' | xargs -r shellcheck >/dev/null 2>&1 && echo "- Shell: shellcheck OK" >> "$SUMMARY_FILE") || echo "- Shell: shellcheck a signalé des problèmes" >> "$SUMMARY_FILE" + (git -C "$TARGET_DIR" ls-files '*.sh' | xargs -r shellcheck >/dev/null 2>&1 && echo "- Shell: shellcheck OK" >> "$SUMMARY_FILE") || echo "- Shell: shellcheck a signalé des problèmes" >> "$SUMMARY_FILE" else echo "- Shell: shellcheck non disponible" >> "$SUMMARY_FILE" fi diff --git a/scripts/agents/run.sh b/scripts/agents/run.sh index 4bc8bf3..2ea6615 100755 --- a/scripts/agents/run.sh +++ b/scripts/agents/run.sh @@ -21,7 +21,7 @@ pushd "$TARGET_DIR" >/dev/null || true before_status_file="$OUTPUT_DIR/.before_status.txt" after_status_file="$OUTPUT_DIR/.after_status.txt" changes_report="$OUTPUT_DIR/changes_applied.md" -(git status --porcelain || true) > "$before_status_file" 2>/dev/null || true +(git -C "$TARGET_DIR" status --porcelain || true) > "$before_status_file" 2>/dev/null || true popd >/dev/null || true usage() { @@ -76,7 +76,7 @@ esac # Capture état après et rapport pushd "$TARGET_DIR" >/dev/null || true -(git status --porcelain || true) > "$after_status_file" 2>/dev/null || true +(git -C "$TARGET_DIR" status --porcelain || true) > "$after_status_file" 2>/dev/null || true { echo "# Modifications appliquées par les agents" echo diff --git a/scripts/scripts/auto-ssh-push.sh b/scripts/scripts/auto-ssh-push.sh index a813ec5..0064500 100755 --- a/scripts/scripts/auto-ssh-push.sh +++ b/scripts/scripts/auto-ssh-push.sh @@ -92,7 +92,7 @@ push_branch() { # Fonction pour push et merge vers main push_and_merge() { - local source_branch=${1:-$(git branch --show-current)} + local source_branch=${1:-$(get_current_branch)} local target_branch=${2:-main} echo "🔄 Push et merge $source_branch -> $target_branch" diff --git a/scripts/scripts/init-ssh-env.sh b/scripts/scripts/init-ssh-env.sh index 1ca7fa2..0118472 100755 --- a/scripts/scripts/init-ssh-env.sh +++ b/scripts/scripts/init-ssh-env.sh @@ -44,8 +44,8 @@ fi # 4. Alias Git print_status "Configuration des alias Git..." -git config --global alias.ssh-push '!f() { git add . && git commit -m "${1:-Auto-commit $(date)}" && git push origin $(git branch --show-current); }; f' -git config --global alias.quick-push '!f() { git add . && git commit -m "Update $(date)" && git push origin $(git branch --show-current); }; f' +git config --global alias.ssh-push '!f() { git add . && git commit -m "${1:-Auto-commit $(date)}" && git push origin $(git rev-parse --abbrev-ref HEAD); }; f' +git config --global alias.quick-push '!f() { git add . && git commit -m "Update $(date)" && git push origin $(git rev-parse --abbrev-ref HEAD); }; f' print_success "Alias Git configurés" # 5. Rendu exécutable des scripts si chemin standard