Skip to content

tools: do not use temp files when merging PRs #57790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions tools/actions/commit-queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,18 @@ for pr in "$@"; do
commit_body=$(git log -1 --pretty='format:%b')
commit_head=$(grep 'Fetched commits as' output | cut -d. -f3 | xargs git rev-parse)

jq -n \
--arg title "${commit_title}" \
--arg body "${commit_body}" \
--arg head "${commit_head}" \
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' > output.json
cat output.json
if ! gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input output.json > output; then
if ! commits="$(
jq -cn \
--arg title "${commit_title}" \
--arg body "${commit_body}" \
--arg head "${commit_head}" \
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' |\
gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input -\
--jq 'if .merged then .sha else halt_error end'
)"; then
commit_queue_failed "$pr"
continue
fi
cat output
if ! commits="$(jq -r 'if .merged then .sha else error("not merged") end' < output)"; then
commit_queue_failed "$pr"
continue
fi
rm output.json
fi

rm output
Expand Down
24 changes: 7 additions & 17 deletions tools/actions/merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,14 @@ git log -1 HEAD^ --pretty='format:%B' | git interpret-trailers --parse --no-divi
commit_title=$(git log -1 --pretty='format:%s')
commit_body=$(git log -1 --pretty='format:%b')

jq -n \
commitSHA="$(
jq -cn \
--arg title "${commit_title}" \
--arg body "${commit_body}" \
--arg head "${commit_head}" \
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' > output.json
cat output.json
if ! gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input output.json > output; then
cat output
echo "Failed to merge $pr"
rm output output.json
exit 1
fi
cat output
if ! commits="$(jq -r 'if .merged then .sha else error("not merged") end' < output)"; then
echo "Failed to merge $pr"
rm output output.json
exit 1
fi
rm output.json output
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' |\
gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input -\
--jq 'if .merged then .sha else halt_error end'
)"

gh pr comment "$pr" --repo "$OWNER/$REPOSITORY" --body "Landed in $commits"
gh pr comment "$pr" --repo "$OWNER/$REPOSITORY" --body "Landed in $commitSHA"
Loading