Files
fn_registry/bash/functions/infra/git_push_if_ahead.md
T
egutierrez fc4180cbb3 chore: auto-commit (129 archivos)
- .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>
2026-06-01 22:23:12 +02:00

1.9 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
git_push_if_ahead function bash infra 1.0.0 impure git_push_if_ahead(repo_dir: string) -> stdout: status line Decide si pushear un repo git usando solo refs locales (sin tocar la red para decidir). Sin upstream hace push -u; con upstream y ahead > 0 pushea; con 0 ahead salta. Si el push falla no aborta — emite [error] y exit 0.
git
push
infra
ahead
upstream
false error_go_core
name desc
repo_dir path al repo git a evaluar; default '.'
linea de estado por stdout: '[push -u] repo (branch)', '[push] repo (branch, N commits ahead)', '[skip] repo (up-to-date)' o '[error] repo: razon' false
bash/functions/infra/git_push_if_ahead.sh

Ejemplo

source bash/functions/infra/git_push_if_ahead.sh

# Pushear si hay commits locales
status=$(git_push_if_ahead $HOME/fn_registry)
echo "$status"
# [push] fn_registry (master, 3 commits ahead)
# o:
# [skip] fn_registry (up-to-date)

# Iterar sobre multiples repos
while IFS= read -r repo; do
    git_push_if_ahead "$repo"
done < <(discover_git_repos $HOME/fn_registry)

Estados de salida

Linea stdout Significado
[push -u] repo (branch) Sin upstream — se hizo push -u origin
[push] repo (branch, N ahead) Tenia commits locales — se pusheo
[skip] repo (up-to-date) 0 ahead localmente — no se toco la red
[error] repo: razon Push rechazo (non-fast-forward, etc.) — se reporta pero exit 0

Notas

rev-list --count @{u}..HEAD solo lee refs locales, no hace fetch. Esto es correcto para un push-only workflow: si en otro PC se hizo push, aqui no tenemos nada local que pushear de todas formas. El error [error] tipicamente indica que la rama remote esta adelante — el caller debe sugerir /full-git-pull.