diff --git a/scripts/conventional.sh b/scripts/conventional.sh index 73e4383..5faa6b3 100755 --- a/scripts/conventional.sh +++ b/scripts/conventional.sh @@ -35,10 +35,16 @@ determine_bump() { local bump="none" while IFS= read -r message; do - # Check for breaking changes + # Check for breaking changes — major wins; finish consuming stdin so the + # upstream pipeline doesn't get EPIPE on its remaining writes. if [[ "$message" =~ ^[a-zA-Z]+(\(.+\))?!: ]] || [[ "$message" =~ BREAKING[[:space:]]CHANGE ]]; then - echo "major" - return + bump="major" + continue + fi + + # Skip further checks once we've locked in major. + if [[ "$bump" == "major" ]]; then + continue fi # Check for features diff --git a/tests/conventional.bats b/tests/conventional.bats index 045056e..d26f09c 100644 --- a/tests/conventional.bats +++ b/tests/conventional.bats @@ -64,6 +64,19 @@ setup() { [[ "$result" == "major" ]] } +@test "determine_bump: consumes the full stream after locking in major (no SIGPIPE)" { + # Producer pipeline that mirrors create-release-pr.sh — many lines piped in, + # with the breaking change up front. If determine_bump returns early, the + # remaining echos hit a closed pipe and emit "Broken pipe" on stderr. + err=$( + { + echo "feat!: break stuff" + for i in $(seq 1 50); do echo "fix: thing ${i}"; done + } | determine_bump 2>&1 >/dev/null + ) + [[ -z "$err" ]] +} + @test "determine_bump: none for non-conventional commits" { result=$(echo "update readme" | determine_bump) [[ "$result" == "none" ]]