`GitHelper.checkout_and_pull` swallows git errors and reports failure only via its return value
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 52/100
Direzione di ricerca
Inizia da Fastlane::Helper::GitHelper.checkout_and_pull e confronta il suo comportamento in caso di errore con quello di create_branch, commit e delete_local_branch_if_exists!. Esamina i chiamanti documentati e decidi quale contratto di errore proposto sia appropriato; il lavoro è completo quando gli errori di checkout o pull non vengono più ignorati silenziosamente, mantenendo al contempo il supporto per i chiamanti che necessitano di un risultato booleano.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Fastlane::Helper::GitHelper.checkout_and_pull swallows all git errors and reports failure only through its return value, so the easy way to call it — ignoring the return — is also the unsafe way.
Summary
checkout_and_pullrescuesStandardErrorand returnstrue/falseinstead of raising.- A caller that ignores the return (the natural, and by far the most common, usage across our repos) silently proceeds after a failed
git checkoutorgit pull. - The failure behavior is inconsistent with its sibling helpers and can't be inferred from the method name (no
!), so callers don't realize they need to guard it.
def self.checkout_and_pull(branch)
branch = branch.first.join('/') if branch.is_a?(Hash)
Action.sh('git', 'checkout', branch)
Action.sh('git', 'pull')
true
rescue StandardError
false
end
The inconsistency
GitHelper has no consistent convention for how git failures surface, and the Ruby ! convention is arguably inverted here — the raising helper carries a bang, the silently-swallowing one doesn't:
| Method | On git failure | Bang? |
|---|---|---|
checkout_and_pull |
swallows → returns false |
no |
create_branch |
raises (no rescue) | no |
commit |
swallows → returns false |
no |
delete_local_branch_if_exists! |
raises (ruby-git) | yes |
How this would have helped us
In WordPress-Android#23001 we added a scheduled lane that resets a rolling branch to trunk, re-downloads translations, and opens a single rolling PR. Its first line is:
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
The job runs on a persistent mac-metal agent with a reused checkout. If the git pull here fails — a network blip, or a stale/diverged local trunk left by a prior run — the error is swallowed and the lane proceeds to cut the sync branch from a stale trunk, then force-pushes and opens/refreshes a PR against the wrong base. Nothing aborts; the failure is invisible until someone notices the PR is behind.
Because the toolkit offers no raising variant, we had to re-implement the guard at the call site:
unless Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
UI.user_error!("Could not check out and pull #{DEFAULT_BRANCH}; aborting translation sync.")
end
Every caller that wants the safe behavior has to write this same boilerplate. A raising default (or an obvious raising variant) would have made the safe path the default one.
Proposed fix
- Add a raising variant —
checkout_and_pull!that raises on failure, keeping the bool version for the (rarer) callers that genuinely want to branch on the result. This matches Ruby's!convention and is non-breaking. - Or raise by default with an opt-out —
checkout_and_pull(branch, fatal: true), defaultingfataltotrueso the safe behavior is the default. (Breaking for any caller currently relying on thefalsereturn.) - At minimum, document that the return value must be checked, and align the
!-naming acrossGitHelperso failure behavior is inferable from the signature.
What we're not asking for
This isn't a blanket "make every helper raise." commit returning a bool is genuinely useful — "nothing to commit" is a common, valid no-op that callers want to sail past (the same WordPress-Android lane relies on exactly that for its prune step). The point is narrower: a failed checkout_and_pull is almost never something a caller wants to continue past, so for this helper the safe path should be the default rather than opt-in boilerplate.
- Lingua principale
- Ruby
- Stelle
- 32
- Fork
- 7
- Merge medio
- 1g 15h
- PR unite (30g)
- 9
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di wordpress-mobile/release-toolkit
-
find_duplicated_keys misses escape-spelled duplicate keys (does not decode `.strings` escapes)Apertabug release-toolkit ruby
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
wordpress-mobile/release-toolkit#740 ·
I maintainer di solito rispondono entro 1 giorno
-
release-toolkit
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
wordpress-mobile/release-toolkit#737 ·
I maintainer di solito rispondono entro 1 giorno
-
release-toolkit
Difficoltà 5/5 Più di una settimana Idoneità per principianti 48/100
wordpress-mobile/release-toolkit#736 ·
I maintainer di solito rispondono entro 1 giorno
-
Make `create_release_backmerge_pull_request` support squash strategyForse di nuovo libera @mokagio l’ha presa 624 giorni fa e non c’è nessuna pull request aperta. Apertabug enhancement
wordpress-mobile/release-toolkit#637 · 1 commento · 3 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
Port automation to strip App Clip from Enterprise target to `release-toolkit`Forse di nuovo libera @mokagio l’ha presa 655 giorni fa e non c’è nessuna pull request aperta. Apertarelease-toolkit
wordpress-mobile/release-toolkit#629 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di wordpress-mobile/release-toolkit
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
TarteelAI/quranic-universal-library#1111 ·
I maintainer di solito rispondono entro 1 giorno
-
Generated cask uses deprecated `postflight` stanza; Homebrew 7 warns on every commandForse già presa @k4kratik l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sachincool/cruft#4 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
auth0/ruby-auth0#840 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
riscv/riscv-unified-db#2859 ·
I maintainer di solito rispondono entro 2 giorni
-
agent-driven deployment documentation future releases nice to have
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno