Skip to content

Commit 82bb228

Browse files
aduh95RafaelGSS
authored andcommitted
tools: do not use temp files when merging PRs
PR-URL: #57790 Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 40dcd4a commit 82bb228

File tree

2 files changed

+16
-30
lines changed

2 files changed

+16
-30
lines changed

tools/actions/commit-queue.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,18 @@ for pr in "$@"; do
8787
commit_body=$(git log -1 --pretty='format:%b')
8888
commit_head=$(grep 'Fetched commits as' output | cut -d. -f3 | xargs git rev-parse)
8989

90-
jq -n \
91-
--arg title "${commit_title}" \
92-
--arg body "${commit_body}" \
93-
--arg head "${commit_head}" \
94-
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' > output.json
95-
cat output.json
96-
if ! gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input output.json > output; then
90+
if ! commits="$(
91+
jq -cn \
92+
--arg title "${commit_title}" \
93+
--arg body "${commit_body}" \
94+
--arg head "${commit_head}" \
95+
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' |\
96+
gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input -\
97+
--jq 'if .merged then .sha else halt_error end'
98+
)"; then
9799
commit_queue_failed "$pr"
98100
continue
99101
fi
100-
cat output
101-
if ! commits="$(jq -r 'if .merged then .sha else error("not merged") end' < output)"; then
102-
commit_queue_failed "$pr"
103-
continue
104-
fi
105-
rm output.json
106102
fi
107103

108104
rm output

tools/actions/merge.sh

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,14 @@ git log -1 HEAD^ --pretty='format:%B' | git interpret-trailers --parse --no-divi
3939
commit_title=$(git log -1 --pretty='format:%s')
4040
commit_body=$(git log -1 --pretty='format:%b')
4141

42-
jq -n \
42+
commitSHA="$(
43+
jq -cn \
4344
--arg title "${commit_title}" \
4445
--arg body "${commit_body}" \
4546
--arg head "${commit_head}" \
46-
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' > output.json
47-
cat output.json
48-
if ! gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input output.json > output; then
49-
cat output
50-
echo "Failed to merge $pr"
51-
rm output output.json
52-
exit 1
53-
fi
54-
cat output
55-
if ! commits="$(jq -r 'if .merged then .sha else error("not merged") end' < output)"; then
56-
echo "Failed to merge $pr"
57-
rm output output.json
58-
exit 1
59-
fi
60-
rm output.json output
47+
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' |\
48+
gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input -\
49+
--jq 'if .merged then .sha else halt_error end'
50+
)"
6151

62-
gh pr comment "$pr" --repo "$OWNER/$REPOSITORY" --body "Landed in $commits"
52+
gh pr comment "$pr" --repo "$OWNER/$REPOSITORY" --body "Landed in $commitSHA"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy