| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 06cd746 commit 51f578a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,25 +6,46 @@ | |||
| 6 | 6 | # To land a PR with this tool: | |
| 7 | 7 | # 1. Run `git node land <pr-id-or-url> --fixupAll` | |
| 8 | 8 | # 2. Copy the hash of the commit at the top of the PR branch. | |
| 9 | - # 3. Run `tools/actions/merge.sh <pr-id-or-url> <commit-hash>`. | ||
| 9 | + # 3. Run `tools/actions/merge.sh <pr-id-or-url> <commit-hash>` or `tools/actions/merge.sh <url-to-PR-commit>`. | ||
| 10 | 10 | ||
| 11 | 11 | set -xe | |
| 12 | 12 | ||
| 13 | 13 | pr=$1 | |
| 14 | 14 | commit_head=$2 | |
| 15 | - shift 2 || { echo "Expected two arguments"; exit 1; } | ||
| 16 | 15 | ||
| 17 | 16 | OWNER=nodejs | |
| 18 | 17 | REPOSITORY=node | |
| 19 | 18 | ||
| 20 | 19 | if expr "X$pr" : 'Xhttps://github.com/[^/]\{1,\}/[^/]\{1,\}/pull/[0-9]\{1,\}' >/dev/null; then | |
| 21 | 20 | OWNER="$(echo "$pr" | awk 'BEGIN { FS = "/" } ; { print $4 }')" | |
| 22 | 21 | REPOSITORY="$(echo "$pr" | awk 'BEGIN { FS = "/" } ; { print $5 }')" | |
| 22 | + [ -n "$commit_head" ] || commit_head="$(echo "$pr" | awk 'BEGIN { FS = "/" } ; { print $9 }')" | ||
| 23 | 23 | pr="$(echo "$pr" | awk 'BEGIN { FS = "/" } ; { print $7 }')" | |
| 24 | - elif ! expr "X$pr" : 'X[0-9]\{1,\}' >/dev/null; then | ||
| 25 | - echo "The first argument should be the PR ID or URL" | ||
| 26 | 24 | fi | |
| 27 | 25 | ||
| 26 | + validation_error= | ||
| 27 | + if ! expr "X${pr}X" : 'X[0-9]\{1,\}X' >/dev/null; then | ||
| 28 | + set +x | ||
| 29 | + echo "Invalid PR ID: $pr" | ||
| 30 | + validation_error=1 | ||
| 31 | + fi | ||
| 32 | + if ! expr "X${commit_head}X" : 'X[a-f0-9]\{40\}X' >/dev/null; then | ||
| 33 | + set +x | ||
| 34 | + echo "Invalid PR head: $commit_head" | ||
| 35 | + validation_error=1 | ||
| 36 | + fi | ||
| 37 | + [ -z "$validation_error" ] || { | ||
| 38 | + echo 'Usage:' | ||
| 39 | + printf '\t%s <pr-id-or-url> <commit-hash>\n' "$0" | ||
| 40 | + echo 'or:' | ||
| 41 | + printf '\t%s <url-to-PR-commit>\n' "$0" | ||
| 42 | + echo 'Examples:' | ||
| 43 | + printf '\t%s 12345 aaaaabbbbbcccccdddddeeeeefffff1111122222\n' "$0" | ||
| 44 | + printf '\t%s https://github.com/%s/pull/12345 aaaaabbbbbcccccdddddeeeeefffff1111122222\n' "$0" "$OWNER/$REPOSITORY" | ||
| 45 | + printf '\t%s https://github.com/%s/pull/12345/commits/aaaaabbbbbcccccdddddeeeeefffff1111122222\n' "$0" "$OWNER/$REPOSITORY" | ||
| 46 | + exit 1 | ||
| 47 | + } | ||
| 48 | + | ||
| 28 | 49 | git log -1 HEAD --pretty='format:%B' | git interpret-trailers --parse --no-divider | \ | |
| 29 | 50 | grep -q -x "^PR-URL: https://github.com/$OWNER/$REPOSITORY/pull/$pr$" || { | |
| 30 | 51 | echo "Invalid PR-URL trailer" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments