Skip to content

Commit 8fa2566

Browse files
ottobackwardsotto
authored and
otto
committed
METRON-2348 prepare-commit broken by github api change (ottobackwards) closes #1580
1 parent dbacbc3 commit 8fa2566

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

dev-utilities/committer-utils/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ When prompted the `[value in brackets]` is used by default. To accept the defau
2828

2929
In the following example, I enter the pull request number when prompted. Using the pull request number, the script can extract most of the remaining required information.
3030

31+
> prepare-commit utilizes [jq](https://stedolan.github.io/jq/) to parse the github api returns, so it is required
32+
3133
1. Execute the script.
3234

3335
The first time the script is run, you will be prompted for additional information including your Apache username, Apache email, and Github username. These values are persisted in `~/.metron-prepare-commit`. Subsequent executions of the script will retrieve these values, rather than prompting you again for them.

dev-utilities/committer-utils/metron-committer-common

+9-3
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,15 @@ function read_pull_request {
128128
fi
129129

130130
# ensure that the pull request exists
131-
PR_EXISTS=$(curl -sI https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/${PR} | grep Status: | sed 's/[^0-9]//g')
132-
if [[ "$PR_EXISTS" != "200" ]]; then
133-
echo "Error: pull request #$PR does not exist"
131+
PR_STATE=$(curl -s https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/${PR} | jq ".state")
132+
PR_MERGEABLE=$(curl -s https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/${PR} | jq ".mergeable_state")
133+
if [[ "$PR_STATE" != "\"open\"" ]]; then
134+
echo "Error: pull request #$PR is not open or does not exist"
135+
exit 1
136+
fi
137+
138+
if [[ "$PR_MERGEABLE" != "\"clean\"" ]] && [[ "$PR_MERGEABLE" != "\"unstable\"" ]]; then
139+
echo "Error: pull request #$PR is not mergable. mergeable_state is $PR_MERGEABLE"
134140
exit 1
135141
fi
136142
}

0 commit comments

Comments
 (0)