8f37b0e81a
discover_git_repos: quitar -type d para cubrir submodulos
y worktrees (.git como archivo, no solo directorio).
full_git_push auto-init: reemplazar bucle hardcodeado
sobre apps/, analysis/, projects/*/{apps,analysis}/ por
iteracion BD-driven sobre TODOS los dir_path indexados.
Cubre cpp/apps/, projects/*/apps/ y cualquier ubicacion
futura sin tocar este codigo.
Detectaba 32 repos; ahora 33. Auto-init detecta 2 missing
(chart_demo, shaders_lab) que antes quedaban fuera.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.5 KiB
Bash
48 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
# discover_git_repos — Encuentra todos los repos git dentro de root_dir.
|
|
# Devuelve paths relativos (sin /.git) en stdout, uno por linea, ordenados.
|
|
# Incluye el propio root_dir si tiene .git. Excluye node_modules, .venv,
|
|
# cpp/vendor, cpp/build, sources, temp, subrepos e interior de .git.
|
|
|
|
discover_git_repos() {
|
|
local root_dir="${1:-.}"
|
|
|
|
if [[ ! -d "$root_dir" ]]; then
|
|
echo "discover_git_repos: directorio '$root_dir' no existe" >&2
|
|
return 1
|
|
fi
|
|
|
|
# Normalizar: convertir a path absoluto para calculos consistentes
|
|
local abs_root
|
|
abs_root="$(cd "$root_dir" && pwd)"
|
|
|
|
# Incluir el propio root si tiene .git
|
|
local results=()
|
|
if [[ -d "$abs_root/.git" ]]; then
|
|
results+=("$abs_root")
|
|
fi
|
|
|
|
# Buscar .git en subdirectorios, con exclusiones.
|
|
# Sin -type d: cubre tambien .git como archivo (submodulos + worktrees).
|
|
while IFS= read -r git_path; do
|
|
local repo_dir="${git_path%/.git}"
|
|
results+=("$repo_dir")
|
|
done < <(find "$abs_root" -mindepth 2 -name ".git" \
|
|
-not -path "*/.git/*" \
|
|
-not -path "*/node_modules/*" \
|
|
-not -path "*/.venv/*" \
|
|
-not -path "*/cpp/vendor/*" \
|
|
-not -path "*/cpp/build/*" \
|
|
-not -path "*/sources/*" \
|
|
-not -path "*/temp/*" \
|
|
-not -path "*/subrepos/*" \
|
|
2>/dev/null | sort)
|
|
|
|
# Imprimir resultados ordenados (uno por linea)
|
|
printf '%s\n' "${results[@]}" | sort
|
|
}
|
|
|
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
discover_git_repos "$@"
|
|
fi
|