Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d1c517f

Browse filesBrowse files
committed
tools: improve backport review script
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #62573 Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent e9d76b2 commit d1c517f
Copy full SHA for d1c517f

1 file changed

+24-7Lines changed: 24 additions & 7 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tools/actions/review_backport.sh‎

Copy file name to clipboardExpand all lines: tools/actions/review_backport.sh
+24-7Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
BACKPORT_PR=$1
44

5+
[ -x "$(command -v gh || true)" ] || {
6+
# shellcheck disable=SC2016
7+
echo 'Missing required `gh` dependency' >&2
8+
exit 1
9+
}
510
[ -n "$BACKPORT_PR" ] || {
6-
echo "Usage:"
7-
echo 'tools/actions/review_backport.sh https://github.com/nodejs/node/pull/<backport-PR-number> | less'
8-
echo 'DIFF_CMD="codium --wait --diff" tools/actions/review_backport.sh https://github.com/nodejs/node/pull/<backport-PR-number>'
9-
echo "Limitations: This tools only supports PRs that landed as single commit, e.g. with 'commit-queue-squash' label."
11+
echo "Usage:" >&2
12+
echo 'tools/actions/review_backport.sh https://github.com/nodejs/node/pull/<backport-PR-number> | less' >&2
13+
echo 'DIFF_CMD="codium --wait --diff" tools/actions/review_backport.sh https://github.com/nodejs/node/pull/<backport-PR-number>' >&2
14+
echo "Limitations: This tools only supports PRs that landed as single commit, e.g. with 'commit-queue-squash' label." >&2
1015

1116
exit 1
1217
}
@@ -15,16 +20,28 @@ SED_CMD='s/^index [a-f0-9]\+..[a-f0-9]\+ \([0-7]\{6\}\)$/index eeeeeeeeee..eeeee
1520

1621
set -ex
1722

23+
BACKPORT_PR_URL=$(gh pr view "$BACKPORT_PR" --json url --jq .url)
24+
1825
ORIGINAL=$(mktemp)
1926
BACKPORT=$(mktemp)
27+
trap 'set -x; rm -f "$ORIGINAL" "$BACKPORT"; set +x; trap - EXIT; exit' EXIT INT HUP
28+
2029
gh pr view "$BACKPORT_PR" --json commits --jq '.[] | map([ .oid, (.messageBody | match("(?:^|\\n)PR-URL: (https?://.+/pull/\\d+)(?:\\n|$)", "g") | .captures | last | .string)] | @tsv) | .[]' \
2130
| while read -r LINE; do
2231
COMMIT_SHA=$(echo "$LINE" | cut -f1)
2332
PR_URL=$(echo "$LINE" | cut -f2)
2433

2534
curl -fsL "$PR_URL.diff" | sed "$SED_CMD" >> "$ORIGINAL"
26-
curl -fsL "$BACKPORT_PR/commits/$COMMIT_SHA.diff" | sed "$SED_CMD" >> "$BACKPORT"
35+
curl -fsL "$BACKPORT_PR_URL/commits/$COMMIT_SHA.diff" | sed "$SED_CMD" >> "$BACKPORT"
2736
done
2837

29-
${DIFF_CMD:-diff} "$ORIGINAL" "$BACKPORT"
30-
rm "$ORIGINAL" "$BACKPORT"
38+
${DIFF_CMD:-diff} "$ORIGINAL" "$BACKPORT" || echo "diff command exited with $?" >&2
39+
40+
set +x
41+
42+
printf "Approve the PR using gh? [y/N] "
43+
read -r r
44+
[ "$r" != "y" ] || {
45+
set -x
46+
gh pr review "$BACKPORT_PR" --approve
47+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.