| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3d50997 commit 18800de
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,10 @@ issueUrl() { | |||
| 18 | 18 | echo "$API_URL/repos/${OWNER}/${REPOSITORY}/issues/${1}" | |
| 19 | 19 | } | |
| 20 | 20 | ||
| 21 | + mergeUrl() { | ||
| 22 | + echo "$API_URL/repos/${OWNER}/${REPOSITORY}/pulls/${1}/merge" | ||
| 23 | + } | ||
| 24 | + | ||
| 21 | 25 | labelsUrl() { | |
| 22 | 26 | echo "$(issueUrl "${1}")/labels" | |
| 23 | 27 | } | |
@@ -55,8 +59,9 @@ git config --local user.email "github-bot@iojs.org" | |||
| 55 | 59 | git config --local user.name "Node.js GitHub Bot" | |
| 56 | 60 | ||
| 57 | 61 | for pr in "$@"; do | |
| 62 | + gitHubCurl "$(labelsUrl "$pr")" GET > labels.json | ||
| 58 | 63 | # Skip PR if CI was requested | |
| 59 | - if gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("request-ci")'; then | ||
| 64 | + if jq -e 'map(.name) | index("request-ci")' < labels.json; then | ||
| 60 | 65 | echo "pr ${pr} skipped, waiting for CI to start" | |
| 61 | 66 | continue | |
| 62 | 67 | fi | |
@@ -70,9 +75,9 @@ for pr in "$@"; do | |||
| 70 | 75 | # Delete the commit queue label | |
| 71 | 76 | gitHubCurl "$(labelsUrl "$pr")"/"$COMMIT_QUEUE_LABEL" DELETE | |
| 72 | 77 | ||
| 73 | - if gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-squash")'; then | ||
| 78 | + if jq -e 'map(.name) | index("commit-queue-squash")' < labels.json; then | ||
| 74 | 79 | MULTIPLE_COMMIT_POLICY="--fixupAll" | |
| 75 | - elif gitHubCurl "$(labelsUrl "$pr")" GET | jq -e 'map(.name) | index("commit-queue-rebase")'; then | ||
| 80 | + elif jq -e 'map(.name) | index("commit-queue-rebase")' < labels.json; then | ||
| 76 | 81 | MULTIPLE_COMMIT_POLICY="" | |
| 77 | 82 | else | |
| 78 | 83 | MULTIPLE_COMMIT_POLICY="--oneCommitMax" | |
@@ -92,17 +97,35 @@ for pr in "$@"; do | |||
| 92 | 97 | git node land --abort --yes | |
| 93 | 98 | continue | |
| 94 | 99 | fi | |
| 95 | - | ||
| 96 | - commits="$(git rev-parse $UPSTREAM/$DEFAULT_BRANCH)...$(git rev-parse HEAD)" | ||
| 97 | 100 | ||
| 98 | - if ! git push $UPSTREAM $DEFAULT_BRANCH >> output 2>&1; then | ||
| 99 | - commit_queue_failed "$pr" | ||
| 100 | - continue | ||
| 101 | + if [ -z "$MULTIPLE_COMMIT_POLICY" ]; then | ||
| 102 | + commits="$(git rev-parse $UPSTREAM/$DEFAULT_BRANCH)...$(git rev-parse HEAD)" | ||
| 103 | + | ||
| 104 | + if ! git push $UPSTREAM $DEFAULT_BRANCH >> output 2>&1; then | ||
| 105 | + commit_queue_failed "$pr" | ||
| 106 | + continue | ||
| 107 | + fi | ||
| 108 | + else | ||
| 109 | + # If there's only one commit, we can use the Squash and Merge feature from GitHub | ||
| 110 | + jq -n \ | ||
| 111 | + --arg title "$(git log -1 --pretty='format:%s')" \ | ||
| 112 | + --arg body "$(git log -1 --pretty='format:%b')" \ | ||
| 113 | + '{merge_method:"squash",commit_title:$title,commit_message:$body}' > output.json | ||
| 114 | + cat output.json | ||
| 115 | + gitHubCurl "$(mergeUrl "$pr")" PUT --data @output.json > output | ||
| 116 | + cat output | ||
| 117 | + if ! commits="$(jq -r 'if .merged then .sha else error("not merged") end' < output)"; then | ||
| 118 | + commit_queue_failed "$pr" | ||
| 119 | + continue | ||
| 120 | + fi | ||
| 121 | + rm output.json | ||
| 101 | 122 | fi | |
| 102 | 123 | ||
| 103 | 124 | rm output | |
| 104 | 125 | ||
| 105 | 126 | gitHubCurl "$(commentsUrl "$pr")" POST --data '{"body": "Landed in '"$commits"'"}' | |
| 106 | 127 | ||
| 107 | - gitHubCurl "$(issueUrl "$pr")" PATCH --data '{"state": "closed"}' | ||
| 128 | + [ -z "$MULTIPLE_COMMIT_POLICY" ] && gitHubCurl "$(issueUrl "$pr")" PATCH --data '{"state": "closed"}' | ||
| 108 | 129 | done | |
| 130 | + | ||
| 131 | + rm -f labels.json | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments