fc4180cbb3
- .claude/agents/fn-analizador/SKILL.md - .claude/agents/fn-constructor/SKILL.md - .claude/agents/fn-executor/SKILL.md - .claude/agents/fn-mejorador/SKILL.md - .claude/agents/fn-orquestador/SKILL.md - .claude/agents/fn-recopilador/SKILL.md - .claude/commands/app.md - .claude/commands/compile.md - .claude/commands/cpp-app.md - .claude/commands/create_functions.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.7 KiB
2.7 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pre_commit_hook_install | function | bash | infra | 1.0.0 | impure | pre_commit_hook_install(repo_dir: string, [--force]) -> void | Instala un hook pre-commit en .git/hooks/pre-commit de un repo dado. El hook invoca scan_secrets_in_dirty para abortar el commit si detecta secrets en archivos staged. Idempotente: si el hook ya esta instalado (marca fn_registry-pre-commit-v1) no lo sobreescribe a menos que se pase --force. |
|
|
false | error_go_core |
|
Imprime INSTALLED <path> o SKIP <path> (already installed). Retorna exit code 1 si repo_dir no es un repo git valido, 2 si el hook existe y no es nuestro sin --force. | false | bash/functions/infra/pre_commit_hook_install.sh |
Ejemplo
source bash/functions/infra/pre_commit_hook_install.sh
# Instalar en el repo actual
pre_commit_hook_install $HOME/fn_registry
# INSTALLED $HOME/fn_registry/.git/hooks/pre-commit
# Idempotente: segunda llamada no sobreescribe
pre_commit_hook_install $HOME/fn_registry
# SKIP $HOME/fn_registry/.git/hooks/pre-commit (already installed)
# Forzar reinstalacion (hace backup del hook anterior)
pre_commit_hook_install $HOME/fn_registry --force
# INSTALLED $HOME/fn_registry/.git/hooks/pre-commit
Notas
Idempotente por diseno: la marca # fn_registry-pre-commit-v1 en el hook generado sirve como identificador. Si el hook existe y tiene la marca, la funcion no sobreescribe a menos que se pase --force.
Si el hook existe pero NO tiene la marca (es un hook ajeno), la funcion falla con exit 2 y un mensaje de error claro. Con --force, se hace backup a pre-commit.bak.<timestamp> antes de reescribir.
El hook generado localiza fn_registry en dos pasos:
- La variable de entorno
FN_REGISTRY_ROOTsi esta definida. - Si el repo donde se hace commit tiene
registry.dben la raiz, asume que el propio repo esfn_registry.
Si no puede localizar fn_registry, el hook imprime un aviso y sale con exit 0 (no bloquea el commit). Esto permite instalar el hook en repos externos al registry sin romper su flujo.
Configurar FN_REGISTRY_ROOT en el perfil del shell para garantizar que el hook siempre encuentre el registry:
export FN_REGISTRY_ROOT=$HOME/fn_registry