| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,30 @@ | |||
| 1 | + #!/bin/sh | ||
| 2 | + | ||
| 3 | + BACKPORT_PR=$1 | ||
| 4 | + | ||
| 5 | + [ -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." | ||
| 10 | + | ||
| 11 | + exit 1 | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + SED_CMD='s/^index [a-f0-9]\+..[a-f0-9]\+ \([0-7]\{6\}\)$/index eeeeeeeeee..eeeeeeeeee \1/g;s/^@@ -[0-9]\+,[0-9]\+ +[0-9]\+,[0-9]\+ @@/@@ -111,1 +111,1 @@/' | ||
| 15 | + | ||
| 16 | + set -ex | ||
| 17 | + | ||
| 18 | + ORIGINAL=$(mktemp) | ||
| 19 | + BACKPORT=$(mktemp) | ||
| 20 | + gh pr view "$BACKPORT_PR" --json commits --jq '.[] | map([ .oid, (.messageBody | match("(?:^|\\n)PR-URL: (https?://.+/pull/\\d+)(?:\\n|$)", "g") | .captures | last | .string)] | @tsv) | .[]' \ | ||
| 21 | + | while read -r LINE; do | ||
| 22 | + COMMIT_SHA=$(echo "$LINE" | cut -f1) | ||
| 23 | + PR_URL=$(echo "$LINE" | cut -f2) | ||
| 24 | + | ||
| 25 | + curl -fsL "$PR_URL.diff" | sed "$SED_CMD" >> "$ORIGINAL" | ||
| 26 | + curl -fsL "$BACKPORT_PR/commits/$COMMIT_SHA.diff" | sed "$SED_CMD" >> "$BACKPORT" | ||
| 27 | + done | ||
| 28 | + | ||
| 29 | + ${DIFF_CMD:-diff} "$ORIGINAL" "$BACKPORT" | ||
| 30 | + rm "$ORIGINAL" "$BACKPORT" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments