Skip to content

Commit

Permalink
tools: simplify commit-queue.sh merge command
Browse files Browse the repository at this point in the history
The mergeUrl() function is only used in one place. It's a one-liner and
inlining it makes the script easier to understand, I think. It also
means no future shellcheck complaints about needing to add error
handling.

PR-URL: #41314
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
  • Loading branch information
Trott authored Dec 27, 2021
1 parent 4624cef commit 67cd4a6
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions tools/actions/commit-queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ DEFAULT_BRANCH=master
COMMIT_QUEUE_LABEL="commit-queue"
COMMIT_QUEUE_FAILED_LABEL="commit-queue-failed"

mergeUrl() {
echo "repos/${OWNER}/${REPOSITORY}/pulls/${1}/merge"
}

commit_queue_failed() {
pr=$1

Expand Down Expand Up @@ -91,7 +87,7 @@ for pr in "$@"; do
--arg head "$(grep 'Fetched commits as' output | cut -d. -f3 | xargs git rev-parse)" \
'{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' > output.json
cat output.json
if ! gh api -X PUT "$(mergeUrl "$pr")" --input output.json > output; then
if ! gh api -X PUT "repos/${OWNER}/${REPOSITORY}/pulls/${pr}/merge" --input output.json > output; then
commit_queue_failed "$pr"
continue
fi
Expand Down

0 comments on commit 67cd4a6

Please sign in to comment.