Commit bbc10f1
committed
tools: simplify and fix commit queue
Use `gh` CLI for CI and commit queue jobs, and use the correct token
to merge PRs.
PR-URL: #40742
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Voltrex <mohammadkeyvanzade94@gmail.com>50- cat output.json26+ body="<details><summary>Commit Queue failed</summary><pre>$(cat output)</pre><a href='$cqurl'>$cqurl</a></details>"27+ echo "$body"5128
52- gitHubCurl "$(commentsUrl "${1}")" POST --data @output.json29+ gh pr comment "$pr" --body "$body"5330
54- rm output output.json31+ rm output5532}5633
5734# TODO(mmarchini): should this be set with whoever added the label for each PR?5835git config --local user.email "github-bot@iojs.org"5936git config --local user.name "Node.js GitHub Bot"6037
6138for pr in "$@"; do62- gitHubCurl "$(labelsUrl "$pr")" GET > labels.json39+ gh pr view "$pr" --json labels --jq ".labels" > labels.json6340 # Skip PR if CI was requested6441 if jq -e 'map(.name) | index("request-ci")' < labels.json; then6542 echo "pr ${pr} skipped, waiting for CI to start"@@ -73,7 +50,7 @@ for pr in "$@"; do7350 fi7451
7552 # Delete the commit queue label76- gitHubCurl "$(labelsUrl "$pr")"/"$COMMIT_QUEUE_LABEL" DELETE53+ gh pr edit "$pr" --remove-label "$COMMIT_QUEUE_LABEL"7754
7855 if jq -e 'map(.name) | index("commit-queue-squash")' < labels.json; then7956 MULTIPLE_COMMIT_POLICY="--fixupAll"@@ -106,14 +83,18 @@ for pr in "$@"; do10683 continue10784 fi10885 else109- # If there's only one commit, we can use the Squash and Merge feature from GitHub86+ # If there's only one commit, we can use the Squash and Merge feature from GitHub.87+ # TODO: use `gh pr merge` when the GitHub CLI allows to customize the commit title (https://github.com/cli/cli/issues/1023).11088 jq -n \11189 --arg title "$(git log -1 --pretty='format:%s')" \11290 --arg body "$(git log -1 --pretty='format:%b')" \11391 --arg head "$(grep 'Fetched commits as' output | cut -d. -f3 | xargs git rev-parse)" \11492 '{merge_method:"squash",commit_title:$title,commit_message:$body,sha:$head}' > output.json11593 cat output.json116- gitHubCurl "$(mergeUrl "$pr")" PUT --data @output.json > output94+ if ! gh api -X PUT "$(mergeUrl "$pr")" --input output.json > output; then95+ commit_queue_failed "$pr"96+ continue97+ fi11798 cat output11899 if ! commits="$(jq -r 'if .merged then .sha else error("not merged") end' < output)"; then119100 commit_queue_failed "$pr"@@ -124,9 +105,9 @@ for pr in "$@"; do124105
125106 rm output126107
127- gitHubCurl "$(commentsUrl "$pr")" POST --data '{"body": "Landed in '"$commits"'"}'108+ gh pr comment "$pr" --body "Landed in $commits"128109
129- [ -z "$MULTIPLE_COMMIT_POLICY" ] && gitHubCurl "$(issueUrl "$pr")" PATCH --data '{"state": "closed"}'110+ [ -z "$MULTIPLE_COMMIT_POLICY" ] && gh pr close "$pr"130111done131112
132113rm -f labels.json| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 5 | + | |
| 6 | + | |
24 | 7 | | |
25 | 8 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 9 | + | |
30 | 10 | | |
31 | 11 | | |
32 | 12 | | |
| |||
35 | 15 | | |
36 | 16 | | |
37 | 17 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
51 | 23 | | |
52 | 24 | | |
53 | 25 | | |
| |||
0 commit comments