diff --git a/scripts/pr.sh b/scripts/pr.sh index 5db6a31..96eaac4 100755 --- a/scripts/pr.sh +++ b/scripts/pr.sh @@ -263,7 +263,9 @@ cmd_merge() { die "merge: $branch changes $vf ($there -> $here): that is a release (just release-patch)" done fi - [ -n "$title" ] || title=$(git log --reverse --format=%s origin/main..HEAD | head -n1) + # sed reads to the end: head would stop early, and git log's SIGPIPE (141) + # would end the script under pipefail. + [ -n "$title" ] || title=$(git log --reverse --format=%s origin/main..HEAD | sed -n 1p) [ -n "$title" ] || die "merge: no commits on $branch beyond main" if release_title "$title"; then die "merge: '$title' starts with 'release ' (the title of release pull requests); pass another title" diff --git a/scripts/test_pr.sh b/scripts/test_pr.sh index c8ff90f..e263fa5 100755 --- a/scripts/test_pr.sh +++ b/scripts/test_pr.sh @@ -164,6 +164,15 @@ expect "merge: squash auto-merge" logged "gh pr merge feat --squash --auto --del check "merge: an existing pull request is reused" 0 merge VERSION "docs: another title" expect "merge: no second pull request" not_logged "gh pr create" +# More log output than a pipe holds: a reader that stops after the first line +# must not end the merge (git log gets SIGPIPE, 141 under pipefail). +setup VERSION 1.2.3 +echo c >>"$repo/work.txt" +# Through stdin: Linux refuses a single argument over 128 KiB. +head -c 200000 /dev/zero | tr '\0' x | git -C "$repo" commit -q -a -F - +check "merge: a long branch log still gives the first commit's subject" 0 merge VERSION +expect "merge: title = the first commit's subject, not the long one" logged "gh pr create --base main --head feat --title fix the widget" + setup VERSION 1.2.3 git -C "$repo" rm -q VERSION git -C "$repo" commit -q -m "a repository without a version"