feat(commands,bash): estandarizar todos los apps y analyses como dataforge/<name>
- /full-git-push y /full-git-pull descubren apps/analyses sin .git y los inicializan/clonan automaticamente contra dataforge/<basename>. - ensure_repo_synced.sh: localizar gitea_create_repo.sh / gitea_push_directory.sh via FN_REGISTRY_INFRA_DIR o FN_REGISTRY_ROOT (mas robusto al sourcing desde directorios arbitrarios y desde zsh). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,10 +8,11 @@ Trae los últimos cambios del remote para el repo principal `fn_registry`, todos
|
||||
|
||||
## Pasos
|
||||
|
||||
### 1. Descubrir repos
|
||||
### 1. Descubrir repos + clonar dataforge/<name> faltantes
|
||||
|
||||
```bash
|
||||
cd /home/egutierrez/fn_registry
|
||||
cd /home/lucas/fn_registry # ajustar al PC
|
||||
|
||||
REPOS=$(find . -name ".git" -type d \
|
||||
-not -path "./.git/*" \
|
||||
-not -path "*/node_modules/*" \
|
||||
@@ -19,10 +20,25 @@ REPOS=$(find . -name ".git" -type d \
|
||||
-not -path "*/cpp/vendor/*" \
|
||||
-not -path "*/cpp/build/*" \
|
||||
-not -path "*/sources/*" \
|
||||
-not -path "*/temp/*" 2>/dev/null | sed 's|/.git$||')
|
||||
-not -path "*/temp/*" \
|
||||
-not -path "*/subrepos/*" 2>/dev/null | sed 's|/.git$||')
|
||||
REPOS=". $REPOS"
|
||||
```
|
||||
|
||||
Despues, despues de `fn sync` (paso 5), hacer **una segunda pasada** para clonar repos `dataforge/<name>` que esten registrados en `pc_locations` o `apps`/`analysis` pero no existan localmente — la metadata vino del API y los repos hay que clonarlos:
|
||||
|
||||
```bash
|
||||
# Listar apps + analysis registradas con dir_path
|
||||
sqlite3 registry.db "SELECT name, dir_path FROM apps WHERE dir_path != '' UNION SELECT name, dir_path FROM analysis WHERE dir_path != '';" | while IFS='|' read name path; do
|
||||
full="$path"
|
||||
if [[ ! -d "$full/.git" && ! -d "$full" ]]; then
|
||||
GITEA_URL=$(pass agentes/gitea-url | head -n1)
|
||||
GITEA_TOKEN=$(pass gitea/dataforge-git-token | head -n1)
|
||||
git clone "https://${GITEA_TOKEN}@${GITEA_URL#https://}/dataforge/${name}.git" "$full" 2>&1 | tail -2
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
### 2. Para cada repo: stash si dirty, pull --ff-only, pop
|
||||
|
||||
```bash
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# /full-git-push — Push de fn_registry + todos los sub-repos + fn sync
|
||||
|
||||
Pushea el repo principal `fn_registry` y todos los sub-repos git anidados (apps externalizadas como `registry_dashboard`, projects con repo propio, etc.), y luego ejecuta `fn sync` para empujar la metadata no regenerable (proposals, apps, projects, analysis, vaults, pc_locations) al `registry_api`.
|
||||
Pushea el repo principal `fn_registry` y todos los sub-repos git anidados (apps y analyses, cada uno como repo independiente bajo `dataforge/<name>` en Gitea), y luego ejecuta `fn sync` para empujar la metadata no regenerable (proposals, apps, projects, analysis, vaults, pc_locations) al `registry_api`.
|
||||
|
||||
**Estandar:** todo `apps/<name>`, `analysis/<name>`, `projects/*/apps/<name>` y `projects/*/analysis/<name>` debe tener su propio repo Gitea bajo `dataforge/<basename>`. Los `subrepos/` de la raiz NO entran (son mirrors upstream que no se pushean desde aqui). Los `vaults/` tampoco — son datos puros con su propio mecanismo de compartir (TBD).
|
||||
|
||||
## Argumento
|
||||
|
||||
@@ -8,10 +10,12 @@ Pushea el repo principal `fn_registry` y todos los sub-repos git anidados (apps
|
||||
|
||||
## Pasos
|
||||
|
||||
### 1. Descubrir repos git en el workspace
|
||||
### 1. Descubrir repos git + apps/analyses sin git en el workspace
|
||||
|
||||
```bash
|
||||
cd /home/egutierrez/fn_registry
|
||||
cd /home/lucas/fn_registry # ajustar al PC
|
||||
|
||||
# 1a) Repos git ya existentes (sin subrepos/, sin cpp/vendor/, sin sources/, sin temp/)
|
||||
REPOS=$(find . -name ".git" -type d \
|
||||
-not -path "./.git/*" \
|
||||
-not -path "*/node_modules/*" \
|
||||
@@ -19,11 +23,37 @@ REPOS=$(find . -name ".git" -type d \
|
||||
-not -path "*/cpp/vendor/*" \
|
||||
-not -path "*/cpp/build/*" \
|
||||
-not -path "*/sources/*" \
|
||||
-not -path "*/temp/*" 2>/dev/null | sed 's|/.git$||')
|
||||
# Añadir la raíz al principio
|
||||
-not -path "*/temp/*" \
|
||||
-not -path "*/subrepos/*" 2>/dev/null | sed 's|/.git$||')
|
||||
REPOS=". $REPOS"
|
||||
|
||||
# 1b) Apps y analyses SIN .git — candidatos a inicializar
|
||||
MISSING=()
|
||||
for d in apps/*/ analysis/*/ projects/*/apps/*/ projects/*/analysis/*/; do
|
||||
d="${d%/}"
|
||||
[[ -d "$d/.git" ]] || MISSING+=("$d")
|
||||
done
|
||||
```
|
||||
|
||||
Si `MISSING` no esta vacio, listarlos al usuario y preguntar si inicializarlos como repos `dataforge/<basename>` antes de continuar (paso 1c).
|
||||
|
||||
### 1c. Inicializar repos faltantes (opcional, requiere confirmacion)
|
||||
|
||||
Para cada `$d` aprobado por el usuario:
|
||||
|
||||
```bash
|
||||
export GITEA_URL=$(pass agentes/gitea-url | head -n1)
|
||||
export GITEA_TOKEN=$(pass gitea/dataforge-git-token | head -n1)
|
||||
export FN_REGISTRY_INFRA_DIR=/home/lucas/fn_registry/bash/functions/infra
|
||||
|
||||
bash -c "
|
||||
source $FN_REGISTRY_INFRA_DIR/ensure_repo_synced.sh
|
||||
ensure_repo_synced '$d' dataforge \"\$(basename '$d')\" master 'chore: initial sync'
|
||||
"
|
||||
```
|
||||
|
||||
**Antes de inicializar**, comprobar que `$d/.gitignore` existe; si no, escribir uno apropiado (ver `.claude/rules/apps_vs_functions.md` para patrones tipicos: excluir `.venv/`, `node_modules/`, binarios, `operations.db*`, `.jupyter*`, `__pycache__/`).
|
||||
|
||||
### 2. Para cada repo, mostrar estado
|
||||
|
||||
```bash
|
||||
|
||||
@@ -38,8 +38,24 @@ ensure_repo_synced() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
local script_dir
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# Localizar las funciones companeras: por env var o por path relativo al
|
||||
# propio script si esta disponible.
|
||||
local script_dir="${FN_REGISTRY_INFRA_DIR:-}"
|
||||
if [[ -z "$script_dir" ]]; then
|
||||
local self="${BASH_SOURCE[0]:-$0}"
|
||||
if [[ -f "$self" ]]; then
|
||||
script_dir="$(cd "$(dirname "$self")" && pwd)"
|
||||
fi
|
||||
fi
|
||||
if [[ -z "$script_dir" || ! -f "$script_dir/gitea_create_repo.sh" ]]; then
|
||||
# Fallback: buscar en FN_REGISTRY_ROOT/bash/functions/infra
|
||||
local root="${FN_REGISTRY_ROOT:-$(cd "$(pwd)" && while [[ "$PWD" != "/" && ! -f "registry.db" ]]; do cd ..; done && pwd)}"
|
||||
script_dir="$root/bash/functions/infra"
|
||||
fi
|
||||
if [[ ! -f "$script_dir/gitea_create_repo.sh" ]]; then
|
||||
echo "ensure_repo_synced: no encuentro gitea_create_repo.sh (script_dir=$script_dir). Setea FN_REGISTRY_INFRA_DIR" >&2
|
||||
return 1
|
||||
fi
|
||||
# shellcheck source=./gitea_create_repo.sh
|
||||
source "$script_dir/gitea_create_repo.sh"
|
||||
# shellcheck source=./gitea_push_directory.sh
|
||||
|
||||
Reference in New Issue
Block a user