Files
fn_registry/bash/functions/infra/discover_git_repos.sh
T
egutierrez 625569485f feat(doctor): add fn doctor CLI + 14 functions for system management
Adds `fn doctor` read-only diagnostic command with subcommands artefacts,
services, sync, uses-functions, unused, and --json flag for agents.
Each subcommand wraps a registry function in functions/infra/.

New functions:
- artefact_doctor, services_status, pc_locations_drift,
  audit_uses_functions, find_unused_functions (Go diagnostics)
- backup_sqlite_db, rotate_backups, wait_for_http, wait_for_port,
  port_kill, tail_journal, pre_commit_hook_install (bash utilities)
- notify_telegram (Go HTTP)
- backup_all pipeline (tag launcher)

Plus prior session leftovers (scan_secrets_in_dirty, append_diary_entry,
git utilities, http_session_cookie_middleware, compile/full-git pipelines).

Fixes pc_locations_drift filepath.Join bug with absolute dir_path.
Documents fn doctor in CLAUDE.md, .claude/rules/fn_doctor.md (rule 23),
docs/architecture.md, CHANGELOG.md (2026-05-07), and diary entry.

First fn doctor uses-functions run found drift in 7/12 apps (deuda
para sincronizar app.md con imports reales).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 01:42:10 +02:00

47 lines
1.4 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
while IFS= read -r git_dir; do
local repo_dir="${git_dir%/.git}"
results+=("$repo_dir")
done < <(find "$abs_root" -mindepth 2 -name ".git" -type d \
-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