This is an automated email from the ASF dual-hosted git repository.
otto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/metron.git
The following commit(s) were added to refs/heads/master by this push:
new 8fa2566 METRON-2348 prepare-commit broken by github api change
(ottobackwards) closes apache/metron#1580
8fa2566 is described below
commit 8fa25664fdff439ba28492bf43e26788691ec84b
Author: ottobackwards <[email protected]>
AuthorDate: Sun May 17 21:31:07 2020 -0400
METRON-2348 prepare-commit broken by github api change (ottobackwards)
closes apache/metron#1580
---
dev-utilities/committer-utils/README.md | 2 ++
dev-utilities/committer-utils/metron-committer-common | 12 +++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/dev-utilities/committer-utils/README.md
b/dev-utilities/committer-utils/README.md
index 0a91759..f0f358f 100644
--- a/dev-utilities/committer-utils/README.md
+++ b/dev-utilities/committer-utils/README.md
@@ -28,6 +28,8 @@ When prompted the `[value in brackets]` is used by default.
To accept the defau
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.
+> prepare-commit utilizes [jq](https://stedolan.github.io/jq/) to parse the
github api returns, so it is required
+
1. Execute the script.
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.
diff --git a/dev-utilities/committer-utils/metron-committer-common
b/dev-utilities/committer-utils/metron-committer-common
index 257bcb0..88dc576 100644
--- a/dev-utilities/committer-utils/metron-committer-common
+++ b/dev-utilities/committer-utils/metron-committer-common
@@ -128,9 +128,15 @@ function read_pull_request {
fi
# ensure that the pull request exists
- PR_EXISTS=$(curl -sI
https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/${PR} | grep Status: |
sed 's/[^0-9]//g')
- if [[ "$PR_EXISTS" != "200" ]]; then
- echo "Error: pull request #$PR does not exist"
+ PR_STATE=$(curl -s
https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/${PR} | jq ".state")
+ PR_MERGEABLE=$(curl -s
https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/${PR} | jq
".mergeable_state")
+ if [[ "$PR_STATE" != "\"open\"" ]]; then
+ echo "Error: pull request #$PR is not open or does not exist"
+ exit 1
+ fi
+
+ if [[ "$PR_MERGEABLE" != "\"clean\"" ]] && [[ "$PR_MERGEABLE" !=
"\"unstable\"" ]]; then
+ echo "Error: pull request #$PR is not mergable. mergeable_state is
$PR_MERGEABLE"
exit 1
fi
}