You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by aw...@apache.org on 2018/08/23 23:48:26 UTC
yetus git commit: YETUS-591. Match git SHA1 with github pull request #
Repository: yetus
Updated Branches:
refs/heads/master 44dc68943 -> 5a2c02552
YETUS-591. Match git SHA1 with github pull request #
Signed-off-by: Jack Bearden <ja...@jackbearden.com>
Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/5a2c0255
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/5a2c0255
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/5a2c0255
Branch: refs/heads/master
Commit: 5a2c02552b11de6a397261d3107f2c40f375215f
Parents: 44dc689
Author: Allen Wittenauer <aw...@apache.org>
Authored: Mon Aug 20 21:19:17 2018 -0700
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Thu Aug 23 16:48:02 2018 -0700
----------------------------------------------------------------------
.../in-progress/precommit-bugsystems.md | 8 +-
precommit/test-patch.d/github.sh | 100 ++++++++++++++++---
2 files changed, 93 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/yetus/blob/5a2c0255/asf-site-src/source/documentation/in-progress/precommit-bugsystems.md
----------------------------------------------------------------------
diff --git a/asf-site-src/source/documentation/in-progress/precommit-bugsystems.md b/asf-site-src/source/documentation/in-progress/precommit-bugsystems.md
index b298f8b..b3b1403 100644
--- a/asf-site-src/source/documentation/in-progress/precommit-bugsystems.md
+++ b/asf-site-src/source/documentation/in-progress/precommit-bugsystems.md
@@ -64,7 +64,7 @@ Using the `--bugzilla-base-url` on the command line or BUGZILLA\_BASE\_URL in a
# GitHub Specific
-GitHub supports the full range of functionality, including putting comments on individual lines. Be aware, however, that test-patch.sh will require that GitHub PRs be fully rebased (i.e., a single commit) in many circumstances.
+GitHub supports the full range of functionality, including putting comments on individual lines. Be aware, however, that test-patch.sh will (generally) require that GitHub PRs be fully rebased (i.e., a single commit) in many circumstances.
By default, the GitHub plug-in assumes that https://github.com is the base URL for GitHub. Enterprise users may override this with the `--github-base-url` for the normal web user interface and `--github-api-url` for the API URL. Personalities may use GITHUB\_API\_URL and GITHUB\_BASE\_URL.
@@ -79,6 +79,12 @@ In order to comment on issues or, depending upon the security setup of the repo,
The default value for GITHUB\_USER is the value of `--project` suffixed with QA. For example,
`--project=yetus` will set `GITHUB_USER=yetusqa`.
+GitHub pull requests may be directly processed on the command line in two ways:
+
+ * GH:(PR number)
+ * GHSHA:(PR SHA1 number)
+
+The GitHub bugsystem plugin will attempt to download the unified diff that the pull request references.
Pull requests that are made off of a specific branch will switch the test repo to that branch, if permitted. If the pull request references a JIRA issue that matches the given JIRA issue regexp in the Subject, the JIRA plug-in will also be invoked as needed.
# JIRA Specific
http://git-wip-us.apache.org/repos/asf/yetus/blob/5a2c0255/precommit/test-patch.d/github.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.d/github.sh b/precommit/test-patch.d/github.sh
index c84fcca..6b220f1 100755
--- a/precommit/test-patch.d/github.sh
+++ b/precommit/test-patch.d/github.sh
@@ -242,21 +242,12 @@ function github_determine_branch
## @param output
## @return 0 on success
## @return 1 on failure
-function github_locate_patch
+function github_locate_pr_patch
{
declare input=$1
declare output=$2
declare githubauth
- if [[ "${OFFLINE}" == true ]]; then
- yetus_debug "github_locate_patch: offline, skipping"
- return 1
- fi
-
- if [[ ! "${input}" =~ ^GH: ]]; then
- return 1
- fi
-
input=${input#GH:}
# https://github.com/your/repo/pull/##
@@ -313,13 +304,11 @@ function github_locate_patch
echo "${PATCHURL}"
# the actual patch file
- ${CURL} --silent --fail \
+ if ! ${CURL} --silent --fail \
--output "${output}" \
--location \
-H "${githubauth}" \
- "${PATCHURL}"
-
- if [[ $? != 0 ]]; then
+ "${PATCHURL}"; then
yetus_debug "github_locate_patch: not a github pull request."
return 1
fi
@@ -332,6 +321,89 @@ function github_locate_patch
return 0
}
+
+## @description a wrapper for github_locate_pr_patch that
+## @description that takes a (likely checkout'ed) github commit
+## @description sha and turns into the the github pr
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param input
+## @param output
+## @return 0 on success
+## @return 1 on failure
+function github_locate_sha_patch
+{
+ declare input=$1
+ declare output=$2
+ declare gitsha
+ declare number
+ declare githubauth
+
+ gitsha=${input#GHSHA:}
+
+ # locate the PR number via GitHub API v3
+ #curl https://api.github.com/search/issues?q=sha:40a7af3377d8087779bf8ad66397947b7270737a\&type:pr\&repo:apache/yetus
+
+ if [[ -n "${GITHUB_USER}"
+ && -n "${GITHUB_PASSWD}" ]]; then
+ githubauth="${GITHUB_USER}:${GITHUB_PASSWD}"
+ elif [[ -n "${GITHUB_TOKEN}" ]]; then
+ githubauth="Authorization: token ${GITHUB_TOKEN}"
+ else
+ githubauth="X-ignore-me: fake"
+ fi
+
+ # Let's pull the PR JSON for later use
+ if ! "${CURL}" --silent --fail \
+ -H "Accept: application/vnd.github.v3.full+json" \
+ -H "${githubauth}" \
+ --output "${PATCH_DIR}/github-search.json" \
+ --location \
+ "${GITHUB_API_URL}/search/issues?q=${gitsha}&type:pr&repo:${GITHUB_REPO}"; then
+ return 1
+ fi
+
+ # shellcheck disable=SC2016
+ number=$("${GREP}" number "${PATCH_DIR}/github-search.json" | \
+ head -1 | \
+ "${AWK}" '{print $NF}')
+ number=${number//\s/}
+ number=${number%,}
+
+ github_locate_pr_patch "GH:${number}" "${output}"
+
+}
+
+
+## @description Handle the various ways to reference a github PR
+## @audience private
+## @stability evolving
+## @replaceable no
+## @param input
+## @param output
+## @return 0 on success
+## @return 1 on failure
+function github_locate_patch
+{
+ declare input=$1
+ declare output=$2
+
+ if [[ "${OFFLINE}" == true ]]; then
+ yetus_debug "github_locate_patch: offline, skipping"
+ return 1
+ fi
+
+ case "${input}" in
+ GH:*)
+ github_locate_pr_patch "${input}" "${output}"
+ ;;
+ GHSHA:*)
+ github_locate_sha_patch "${input}" "${output}"
+ ;;
+ esac
+}
+
function github_linecomments
{
declare plugin=$1