7d82359a45
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5.4 KiB
5.4 KiB
Capability: git
Operaciones git y Gitea: descubrir repos, clonar, commit, push/pull, hooks, gestión de ramas TBD, webhooks y sincronización entre PCs. Cubre tanto el lado local (git CLI) como el lado remoto (Gitea API REST).
Funciones
| ID | Firma | Que hace |
|---|---|---|
discover_git_repos_bash_infra |
discover_git_repos(root_dir: string) -> string |
Lista todos los repos git bajo un directorio raiz (find -name .git). Base de full_git_push/pull. |
git_pull_with_stash_bash_infra |
git_pull_with_stash(repo_dir: string) -> string |
Stashea cambios dirty, hace pull --ff-only, recupera stash. Retorna estado: ok/already-up-to-date/diverged/stash-conflict. |
git_push_if_ahead_bash_infra |
git_push_if_ahead(repo_dir: string) -> string |
Push solo si hay commits locales adelantados al remoto. No hace nada si ya esta sincronizado. |
git_auto_commit_dirty_bash_infra |
git_auto_commit_dirty(repo_dir: string, message: string) -> string |
Commitea todos los cambios dirty con mensaje automatico. Retorna el subject del commit o vacío si no habia cambios. |
ensure_repo_synced_bash_infra |
ensure_repo_synced(dir: string, owner: string, repo: string, branch: string, msg: string) -> void |
Inicializa git en un directorio, crea repo en Gitea si no existe, commitea y pushea. Idempotente. |
gitea_create_repo_bash_infra |
gitea_create_repo(owner: string, repo: string) -> json |
Crea repo en Gitea via API REST. Requiere GITEA_URL y GITEA_TOKEN. |
gitea_push_directory_bash_infra |
gitea_push_directory(dir: string, owner: string, repo: string, branch: string, msg: string) -> void |
Push de un directorio local a Gitea. Inicializa git si hace falta. |
gitea_list_repos_bash_infra |
gitea_list_repos(owner: string) -> json |
Lista repos de un usuario/org en Gitea via API. |
gitea_add_collaborator_bash_infra |
gitea_add_collaborator(owner: string, repo: string, user: string, permission: string) -> void |
Añade colaborador a un repo Gitea con permiso dado (read/write/admin). |
gitea_create_webhook_bash_infra |
gitea_create_webhook(owner: string, repo: string, url: string, secret: string) -> json |
Crea webhook push en repo Gitea apuntando a una URL (ej. deploy_server). |
tbd_branch_create_bash_infra |
tbd_branch_create(issue_num: string, slug: string) -> void |
Crea rama TBD issue/<N>-<slug> desde master actualizado. |
tbd_branch_finish_bash_infra |
tbd_branch_finish(branch: string) -> void |
Merge --no-ff de rama TBD a master, push y elimina la rama. |
git_hook_audit_app_drift_bash_infra |
git_hook_audit_app_drift() -> void |
Hook pre-commit que detecta drift entre imports reales y uses_functions del app.md. |
pre_commit_hook_install_bash_infra |
pre_commit_hook_install(repo_dir: string) -> void |
Instala hooks pre-commit en un repo git local. |
scan_secrets_in_dirty_bash_cybersecurity |
scan_secrets_in_dirty(repo_dir: string) -> string |
Escanea archivos dirty de un repo buscando patrones de secrets antes de commitear. |
full_git_pull_bash_pipelines |
full_git_pull() -> stdout |
Pull de fn_registry + todos los sub-repos + submodulos + fn sync. |
full_git_push_bash_pipelines |
full_git_push([commit_message]) -> stdout |
Commit + push de fn_registry + todos los sub-repos + fn sync. |
gitea_init_app_bash_pipelines |
gitea_init_app(app_dir: string, owner: string, repo: string) -> void |
Inicializa repo Gitea para una app nueva: git init, crea repo remoto, primer commit, push. |
clone_project_subrepos_bash_pipelines |
clone_project_subrepos <project_id> [--owner OWNER] [--dry-run] |
Clona todos los sub-repos (apps + analysis) de un project en el PC actual. |
Ejemplo canonico
# --- Flujo 1: PC nuevo — traer un project completo ---
# Solo tienes fn_registry clonado. Quieres trabajar en fn_monitoring.
./fn run clone_project_subrepos fn_monitoring
# KIND NAME STATUS
# ---------- ----------------------------------- -------
# app call_monitor [cloned]
# app registry_dashboard [cloned]
# app sqlite_api [cloned]
# analysis domain_coverage_gaps [cloned]
#
# Siguiente paso sugerido:
# cd /home/lucas/fn_registry && CGO_ENABLED=1 ./fn index && ./fn sync
CGO_ENABLED=1 ./fn index && ./fn sync
# --- Flujo 2: Push diario de todos los repos ---
./fn run full_git_push "feat: nueva funcion X"
# Descubre repos, escanea secrets, commitea dirty trees, pushea adelantados, fn sync
# --- Flujo 3: Crear app nueva con sub-repo Gitea ---
./fn run gitea_init_app apps/mi_app dataforge mi_app
# --- Flujo 4: Rama TBD para una issue ---
# (desde el directorio de la app)
source bash/functions/infra/tbd_branch_create.sh
tbd_branch_create 0123 nueva-feature
# ... trabajo ...
source bash/functions/infra/tbd_branch_finish.sh
tbd_branch_finish issue/0123-nueva-feature
Fronteras
- No gestiona credenciales: el grupo asume SSH key o credential helper configurados. Para secrets usa
pass_get_bash_infra(grupo separado). - No hace rebase interactivo: TBD usa merge --no-ff, nunca rebase.
- No clona vaults:
clone_project_subreposomite vaults deliberadamente (son symlinks a datos externos). - No hace deploy: push a remoto != deploy a VPS. Para deploy ver grupo
docker/deploy_server. - No gestiona submodulos de forma independiente: los submodulos se actualizan dentro de
full_git_pull, no hay función atómica de submodulo separada.