chore(commands): auto-commit full-git-push.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -101,21 +101,38 @@ done
|
|||||||
|
|
||||||
`generate_auto_message` debe inspeccionar `git diff --cached --stat` y producir un subject como `feat(notebook): N cambios` cuando todos los paths comparten prefijo, o `chore: auto-commit` si están dispersos.
|
`generate_auto_message` debe inspeccionar `git diff --cached --stat` y producir un subject como `feat(notebook): N cambios` cuando todos los paths comparten prefijo, o `chore: auto-commit` si están dispersos.
|
||||||
|
|
||||||
### 4. Push de cada repo
|
### 4. Push solo de repos con cambios locales (NO usar `git push` ciego)
|
||||||
|
|
||||||
|
**Filtrar primero, pushear despues.** Sobre 30+ repos, hacer `git push` en todos (incluso "Everything up-to-date") cuesta 30-90s en handshakes SSH. Usar refs locales (sin red) para decidir si hay algo que pushear:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
for r in $REPOS; do
|
for r in $REPOS; do
|
||||||
( cd "$r" \
|
( cd "$r" \
|
||||||
&& BRANCH=$(git rev-parse --abbrev-ref HEAD) \
|
&& BRANCH=$(git rev-parse --abbrev-ref HEAD) \
|
||||||
&& if git rev-parse --abbrev-ref --symbolic-full-name @{u} >/dev/null 2>&1; then
|
&& UPSTREAM_OK=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null) \
|
||||||
git push origin "$BRANCH" 2>&1 | tail -3
|
&& if [ -z "$UPSTREAM_OK" ]; then
|
||||||
else
|
echo "[push -u] $r ($BRANCH)"
|
||||||
git push -u origin "$BRANCH" 2>&1 | tail -3
|
git push -u origin "$BRANCH" 2>&1 | tail -3
|
||||||
|
else
|
||||||
|
AHEAD=$(git rev-list --count @{u}..HEAD 2>/dev/null)
|
||||||
|
if [ "${AHEAD:-0}" -gt 0 ]; then
|
||||||
|
echo "[push] $r ($BRANCH, $AHEAD commits ahead)"
|
||||||
|
git push origin "$BRANCH" 2>&1 | tail -3
|
||||||
|
else
|
||||||
|
echo "[skip] $r (up-to-date local refs)"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reglas:
|
||||||
|
- Sin upstream → `git push -u` (siempre).
|
||||||
|
- Con upstream y `rev-list @{u}..HEAD` > 0 → push.
|
||||||
|
- Con upstream y 0 ahead → skip (ni siquiera intentar).
|
||||||
|
|
||||||
|
`rev-list @{u}..HEAD` solo lee refs locales, no toca la red. Esto es seguro porque cualquier commit local hecho en este PC ya esta a partir del paso 3 (auto-commit). Si en otro PC se hizo push y aqui no se ha hecho pull, sigue siendo correcto: no tenemos nada local que pushear.
|
||||||
|
|
||||||
Si `push` rechaza por non-fast-forward (rama behind), no abortar el resto. Reportar ese repo concreto y sugerir `/full-git-pull` antes; seguir con los demás repos.
|
Si `push` rechaza por non-fast-forward (rama behind), no abortar el resto. Reportar ese repo concreto y sugerir `/full-git-pull` antes; seguir con los demás repos.
|
||||||
|
|
||||||
### 5. fn sync
|
### 5. fn sync
|
||||||
|
|||||||
Reference in New Issue
Block a user