Repository navigation
feat: add --strict to report failed repositories in the exit status - #6
Merged
Merged
Conversation
By default git-parallel exits with 0 even when the command fails in some or all repositories: the batches are waited for with a bare `wait`, and each job ends with `echo`, so the command's status is lost twice. The default is documented as historical behavior and stays unchanged. --strict (opt-in): - every job is waited for by its PID and its exit status is collected (the job now returns the command's status; frozen repositories return 0) - all repositories still run; the exit status is 1 when the command failed in at least one, and the failed repositories are listed on stderr with their own status, also with --silent - SIGHUP/SIGINT/SIGQUIT/SIGTERM kill the running commands, remove the temporary files and exit with 128 + the signal number The help, the man page and the README describe the exit status. New tests cover success, partial and total failure, per-repository statuses across batches, frozen repositories, --silent, no repositories, SIGTERM and SIGINT. Existing tests are unchanged. Claude-Session: https://claude.ai/code/session_01RbGbwRHvCEhsKLZfbvbbRg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
git-parallel always exits with 0, even when the command fails in some or all repositories. This is documented as historical behavior (
test_error_propagation), so scripts cannot rely on the exit status to detect a failedpull/fetch.Root Cause
Each batch is waited for with a bare
wait, which returns 0 whatever the jobs returned, and each job (git::parallel::execute) ends withecho, so the command's own status is lost as well.Solution
Add an opt-in
--strict; the default is unchanged.wait "$pid"(in both modes) and, with--strict, its status is collected.executenow returns the command's status; a frozen repository returns 0.--strict; stderr lists the failed repositories in order with their own status, also under--silent:git-parallel: interrupted by SIG<NAME>on stderr, exit 128 + signal (130/143/129/131). Without--strictthe old handler (SIGKILL of the whole tree, git-parallel included) is kept.Security Impact
None. No new input is evaluated; command handling is unchanged.
Compatibility
Default behavior, output and exit status are unchanged; the existing 20 tests are untouched and pass.
--strictis a new long option only.Tests
8 new tests in
tests/run.sh: success, partial failure with--jobs 3/2/1(failure in every batch position), all fail (128) and command not found (127), distinct statuses per repository across batches (3, 42) and the last job of the last batch, frozen repositories,--silent, no repositories, SIGTERM (143) and SIGINT (130) with commands killed and temp files removed,--help.make check(bash 5.3) andTEST_BASH=/bin/bash tests/run.sh(bash 3.2): 28 passed, 0 failed.waitreplaced by a barewait(partial failure, statuses and frozen/silent tests fail).CI
The existing matrix (Linux/macOS, bash 3.2/4/5) runs the new tests.
Migration
None. Use
git parallel --strict -- ...where the exit status matters.Risks
Low. The default path now waits per PID instead of a bare
wait, which waits for the same set of jobs.https://claude.ai/code/session_01RbGbwRHvCEhsKLZfbvbbRg