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 2019/04/12 17:46:03 UTC
[yetus] branch master updated: YETUS-724. github diff vs. patch
This is an automated email from the ASF dual-hosted git repository.
aw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yetus.git
The following commit(s) were added to refs/heads/master by this push:
new e2f9288 YETUS-724. github diff vs. patch
e2f9288 is described below
commit e2f92881e62e16999c09a7f1b7f93c41deeb3d8d
Author: Allen Wittenauer <aw...@apache.org>
AuthorDate: Tue Nov 27 09:54:21 2018 -0800
YETUS-724. github diff vs. patch
Signed-off-by: Allen Wittenauer <aw...@apache.org>
---
precommit/src/main/shell/core.d/01-common.sh | 17 +++++
precommit/src/main/shell/core.d/change-analysis.sh | 5 +-
precommit/src/main/shell/core.d/patchfiles.sh | 69 +++++++++++++----
precommit/src/main/shell/smart-apply-patch.sh | 14 ++--
precommit/src/main/shell/test-patch.d/github.sh | 42 ++++++----
precommit/src/main/shell/test-patch.d/gitlab.sh | 31 +++++---
precommit/src/main/shell/test-patch.d/jira.sh | 9 ++-
precommit/src/main/shell/test-patch.sh | 89 +++++++++++-----------
8 files changed, 184 insertions(+), 92 deletions(-)
diff --git a/precommit/src/main/shell/core.d/01-common.sh b/precommit/src/main/shell/core.d/01-common.sh
index a175deb..e2c8d68 100755
--- a/precommit/src/main/shell/core.d/01-common.sh
+++ b/precommit/src/main/shell/core.d/01-common.sh
@@ -776,4 +776,21 @@ function add_version_data
if [[ -n "${name}" ]] && [[ -n "${version}" ]]; then
VERSION_DATA+=("$1=$2")
fi
+}
+
+## @description generate a stack trace when in debug mode
+## @audience public
+## @stability stable
+## @replaceable no
+## @return exits
+function generate_stack
+{
+ declare -i frame
+
+ frame=0
+
+ while caller "${frame}"; do
+ ((frame++));
+ done
+ exit 1
}
\ No newline at end of file
diff --git a/precommit/src/main/shell/core.d/change-analysis.sh b/precommit/src/main/shell/core.d/change-analysis.sh
index 98bfc83..430139d 100755
--- a/precommit/src/main/shell/core.d/change-analysis.sh
+++ b/precommit/src/main/shell/core.d/change-analysis.sh
@@ -43,7 +43,7 @@ function find_buildfile_dir
done
}
-## @description List of files that ${PATCH_DIR}/patch modifies
+## @description List of files that ${INPUT_APPLIED_FILE} modifies
## @audience private
## @stability stable
## @replaceable no
@@ -53,6 +53,7 @@ function find_changed_files
declare line
BUILDMODE=${BUILDMODE:-patch}
+ INPUT_APPLIED_FILE=${INPUT_APPLIED_FILE:-${PATCH_DIR}/patch}
pushd "${BASEDIR}" >/dev/null || return 1
@@ -71,7 +72,7 @@ function find_changed_files
done < <(
"${AWK}" 'function p(s){sub("^[ab]/","",s); if(s!~"^/dev/null"){print s}}
/^diff --git / { p($3); p($4) }
- /^(\+\+\+|---) / { p($2) }' "${PATCH_DIR}/patch" | sort -u)
+ /^(\+\+\+|---) / { p($2) }' "${INPUT_APPLIED_FILE}" | sort -u)
;;
esac
popd >/dev/null || return 1
diff --git a/precommit/src/main/shell/core.d/patchfiles.sh b/precommit/src/main/shell/core.d/patchfiles.sh
index e038381..dbed125 100755
--- a/precommit/src/main/shell/core.d/patchfiles.sh
+++ b/precommit/src/main/shell/core.d/patchfiles.sh
@@ -14,6 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+#shellcheck disable=SC2034
+INPUT_PATCH_FILE=""
+#shellcheck disable=SC2034
+INPUT_DIFF_FILE=""
+#shellcheck disable=SC2034
+INPUT_APPLIED_FILE=""
+#shellcheck disable=SC2034
+INPUT_APPLY_TYPE=""
PATCH_METHOD=""
PATCH_METHODS=("gitapply" "patchcmd")
PATCH_LEVEL=0
@@ -89,6 +97,10 @@ function patch_file_hinter
{
declare patch=$1
+ if [[ -z "${patch}" ]]; then
+ generate_stack
+ fi
+
if [[ -z "${PATCH_HINT}" ]] && [[ -z "${PATCH_METHOD}" ]]; then
if head -n 1 "${patch}" | "${GREP}" -q -E "^From [a-z0-9]* Mon Sep 17 00:00:00 2001" &&
"${GREP}" -q "^From: " "${patch}" &&
@@ -101,7 +113,9 @@ function patch_file_hinter
}
## @description Given ${PATCH_OR_ISSUE}, determine what type of patch file is in use,
-## @description and do the necessary work to place it into ${PATCH_DIR}/patch.
+## @description and do the necessary work to place it into ${INPUT_PATCH_FILE}.
+## @description If the system support diff files as well, put the diff version in
+## @description ${INPUT_DIFF_FILE} so that any supported degraded modes work.
## @audience private
## @stability evolving
## @replaceable no
@@ -120,22 +134,27 @@ function locate_patch
cleanup_and_exit 1
fi
+ INPUT_PATCH_FILE="${PATCH_DIR}/input.patch"
+ INPUT_DIFF_FILE="${PATCH_DIR}/input.diff"
+
echo "Processing: ${PATCH_OR_ISSUE}"
# it's a declarely provided file
if [[ -f ${PATCH_OR_ISSUE} ]]; then
patchfile="${PATCH_OR_ISSUE}"
PATCH_SYSTEM=generic
- if [[ -f "${PATCH_DIR}/patch" ]]; then
- "${DIFF}" -q "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch" >/dev/null
- if [[ $? -eq 1 ]]; then
- rm "${PATCH_DIR}/patch"
+ if [[ -f "${INPUT_PATCH_FILE}" ]]; then
+ if ! "${DIFF}" -q "${PATCH_OR_ISSUE}" "${INPUT_PATCH_FILE}" >/dev/null; then
+ rm "${INPUT_PATCH_FILE}"
fi
fi
else
# run through the bug systems. maybe they know?
for bugsys in "${BUGSYSTEMS[@]}"; do
if declare -f "${bugsys}_locate_patch" >/dev/null 2>&1; then
- if "${bugsys}_locate_patch" "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"; then
+ if "${bugsys}_locate_patch" \
+ "${PATCH_OR_ISSUE}" \
+ "${INPUT_PATCH_FILE}" \
+ "${INPUT_DIFF_FILE}"; then
gotit=true
PATCH_SYSTEM=${bugsys}
fi
@@ -148,7 +167,7 @@ function locate_patch
# ok, none of the bug systems know. let's see how smart we are
if [[ ${gotit} == false ]]; then
- if ! generic_locate_patch "${PATCH_OR_ISSUE}" "${PATCH_DIR}/patch"; then
+ if ! generic_locate_patch "${PATCH_OR_ISSUE}" "${INPUT_PATCH_FILE}"; then
yetus_error "ERROR: Unsure how to process ${PATCH_OR_ISSUE}."
cleanup_and_exit 1
fi
@@ -158,9 +177,9 @@ function locate_patch
yetus_debug "Determined patch system to be ${PATCH_SYSTEM}"
- if [[ ! -f "${PATCH_DIR}/patch"
+ if [[ ! -f "${INPUT_PATCH_FILE}"
&& -f "${patchfile}" ]]; then
- if cp "${patchfile}" "${PATCH_DIR}/patch"; then
+ if cp "${patchfile}" "${INPUT_PATCH_FILE}"; then
echo "Patch file ${patchfile} copied to ${PATCH_DIR}"
else
yetus_error "ERROR: Could not copy ${patchfile} to ${PATCH_DIR}"
@@ -189,7 +208,7 @@ function patchfile_verify_zero
# shellcheck disable=SC2016
changed_files1=$("${AWK}" 'function p(s){if(s!~"^/dev/null"){print s}}
/^diff --git / { p($3); p($4) }
- /^(\+\+\+|---) / { p($2) }' "${PATCH_DIR}/patch" | sort -u)
+ /^(\+\+\+|---) / { p($2) }' "${INPUT_PATCH_FILE}" | sort -u)
# maybe we interpreted the patch wrong? check the log file
# shellcheck disable=SC2016
@@ -233,7 +252,7 @@ function gitapply_dryrun
while [[ ${prefixsize} -lt 2
&& -z ${PATCH_METHOD} ]]; do
- if yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
+ if yetus_run_and_redirect "${PATCH_DIR}/input-dryrun.log" \
"${GIT}" apply --binary -v --check "-p${prefixsize}" "${patchfile}"; then
PATCH_LEVEL=${prefixsize}
PATCH_METHOD=gitapply
@@ -243,7 +262,7 @@ function gitapply_dryrun
done
if [[ ${prefixsize} -eq 0 ]]; then
- if ! patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"; then
+ if ! patchfile_verify_zero "${PATCH_DIR}/input-dryrun.log"; then
PATCH_METHOD=""
PATCH_LEVEL=""
gitapply_dryrun "${patchfile}" 1
@@ -264,7 +283,7 @@ function patchcmd_dryrun
while [[ ${prefixsize} -lt 2
&& -z ${PATCH_METHOD} ]]; do
# shellcheck disable=SC2153
- if yetus_run_and_redirect "${PATCH_DIR}/patch-dryrun.log" \
+ if yetus_run_and_redirect "${PATCH_DIR}/input-dryrun.log" \
"${PATCH}" "-p${prefixsize}" -E --dry-run < "${patchfile}"; then
PATCH_LEVEL=${prefixsize}
PATCH_METHOD=patchcmd
@@ -274,7 +293,7 @@ function patchcmd_dryrun
done
if [[ ${prefixsize} -eq 0 ]]; then
- if ! patchfile_verify_zero "${PATCH_DIR}/patch-dryrun.log"; then
+ if ! patchfile_verify_zero "${PATCH_DIR}/input-dryrun.log"; then
PATCH_METHOD=""
PATCH_LEVEL=""
patchcmd_dryrun "${patchfile}" 1
@@ -314,6 +333,26 @@ function patchfile_dryrun_driver
return 1
}
+## @description dryrun both PATCH and DIFF and determine which one to use
+## @replaceable no
+## @audience private
+## @stability evolving
+function dryrun_both_files
+{
+ # always prefer the patch file since git format patch files support a lot more
+ if [[ -f "${INPUT_PATCH_FILE}" ]] && patchfile_dryrun_driver "${INPUT_PATCH_FILE}"; then
+ INPUT_APPLY_TYPE="patch"
+ INPUT_APPLIED_FILE="${INPUT_PATCH_FILE}"
+ return 0
+ elif [[ -f "${INPUT_DIFF_FILE}" ]] && patchfile_dryrun_driver "${INPUT_DIFF_FILE}"; then
+ INPUT_APPLY_TYPE="diff"
+ INPUT_APPLIED_FILE="${INPUT_DIFF_FILE}"
+ return 0
+ else
+ return 1
+ fi
+}
+
## @description git patch apply
## @replaceable no
## @audience private
@@ -328,7 +367,7 @@ function gitapply_apply
extraopts="--whitespace=fix"
fi
- echo "Applying the patch:"
+ echo "Applying the changes:"
yetus_run_and_redirect "${PATCH_DIR}/apply-patch-git-apply.log" \
"${GIT}" apply --binary ${extraopts} -v --stat --apply "-p${PATCH_LEVEL}" "${patchfile}"
${GREP} -v "^Checking" "${PATCH_DIR}/apply-patch-git-apply.log"
diff --git a/precommit/src/main/shell/smart-apply-patch.sh b/precommit/src/main/shell/smart-apply-patch.sh
index 049294e..20a7e57 100755
--- a/precommit/src/main/shell/smart-apply-patch.sh
+++ b/precommit/src/main/shell/smart-apply-patch.sh
@@ -405,6 +405,7 @@ plugins_initialize
locate_patch
if [[ "${REPORTONLY}" = true ]]; then
+ INPUT_APPLIED_FILE="${INPUT_PATCH_FILE}"
patch_reports
cleanup_and_exit 0
fi
@@ -418,19 +419,22 @@ if [[ ${COMMITMODE} = true ]]; then
fi
PATCH_METHODS=("gitam" "${PATCH_METHODS[@]}")
fi
-patch_file_hinter "${PATCH_DIR}/patch"
-patchfile_dryrun_driver "${PATCH_DIR}/patch"
-RESULT=$?
-if [[ ${RESULT} -gt 0 ]]; then
+if ! dryrun_both_files; then
yetus_error "ERROR: Aborting! ${PATCH_OR_ISSUE} cannot be verified."
cleanup_and_exit ${RESULT}
fi
+patch_file_hinter "${INPUT_APPLIED_FILE}"
+
+if [[ "${INPUT_APPLIED_FILE}" == "${INPUT_DIFF_FILE}" ]]; then
+ yetus_error "WARNING: "Used diff version of patch file. Binary files and potentially other changes not applied. Please rebase and squash commits if necessary.""
+fi
+
pushd "${BASEDIR}" >/dev/null || exit 1
if [[ ${PATCH_DRYRUNMODE} == false ]]; then
- patchfile_apply_driver "${PATCH_DIR}/patch" "${GPGSIGN}"
+ patchfile_apply_driver "${INPUT_APPLIED_FILE}" "${GPGSIGN}"
RESULT=$?
fi
diff --git a/precommit/src/main/shell/test-patch.d/github.sh b/precommit/src/main/shell/test-patch.d/github.sh
index b5a48bd..9d95085 100755
--- a/precommit/src/main/shell/test-patch.d/github.sh
+++ b/precommit/src/main/shell/test-patch.d/github.sh
@@ -93,8 +93,9 @@ function github_parse_args
## @description WARNING: Called from JIRA plugin!
function github_jira_bridge
{
- declare fileloc=$1
- declare jsonloc=$2
+ declare jsonloc=$1
+ declare patchout=$2
+ declare diffout=$3
declare urlfromjira
# shellcheck disable=SC2016
@@ -109,7 +110,7 @@ function github_jira_bridge
GITHUB_BRIDGED=true
yetus_debug "github_jira_bridge: Checking url ${urlfromjira}"
github_breakup_url "${urlfromjira}"
- github_locate_patch GH:"${GITHUB_ISSUE}" "${fileloc}"
+ github_locate_patch GH:"${GITHUB_ISSUE}" "${patchout}" "${diffout}"
}
## @description given a URL, break it up into github plugin globals
@@ -259,7 +260,8 @@ function github_determine_branch
function github_locate_pr_patch
{
declare input=$1
- declare output=$2
+ declare patchout=$2
+ declare diffout=$3
declare githubauth
declare apiurl
@@ -290,8 +292,8 @@ function github_locate_pr_patch
return 1
fi
- # we always pull the .patch version (even if .diff was given)
- # with the assumption that this way binary files work.
+ # we always pull both the .patch and .diff versions
+ # but set the default to be .patch so that binary files work.
# The downside of this is that the patch files are
# significantly larger and therefore take longer to process
@@ -327,11 +329,22 @@ function github_locate_pr_patch
# the actual patch file
if ! "${CURL}" --silent --fail \
-H "Accept: application/vnd.github.v3.patch" \
- --output "${output}" \
+ --output "${patchout}" \
+ --location \
+ "${githubauth[@]}" \
+ "${GITHUB_API_URL}/repos/${GITHUB_REPO}/pulls/${input}"; then
+ yetus_debug "github_locate_patch: not a github pull request."
+ return 1
+ fi
+
+ echo " Diff data at $(date)"
+ if ! "${CURL}" --silent --fail \
+ -H "Accept: application/vnd.github.v3.diff" \
+ --output "${diffout}" \
--location \
"${githubauth[@]}" \
"${apiurl}"; then
- yetus_debug "github_locate_patch: cannot download patch"
+ yetus_debug "github_locate_patch: cannot download diff"
return 1
fi
@@ -357,7 +370,8 @@ function github_locate_pr_patch
function github_locate_sha_patch
{
declare input=$1
- declare output=$2
+ declare patchout=$2
+ declare diffout=$3
declare gitsha
declare number
declare githubauth
@@ -406,8 +420,7 @@ function github_locate_sha_patch
return 0
fi
- github_locate_pr_patch "GH:${number}" "${output}"
-
+ github_locate_pr_patch "GH:${number}" "${patchout}" "${diffout}"
}
@@ -422,7 +435,8 @@ function github_locate_sha_patch
function github_locate_patch
{
declare input=$1
- declare output=$2
+ declare patchout=$2
+ declare diffout=$3
if [[ "${OFFLINE}" == true ]]; then
yetus_debug "github_locate_patch: offline, skipping"
@@ -431,10 +445,10 @@ function github_locate_patch
case "${input}" in
GHSHA:*)
- github_locate_sha_patch "${input}" "${output}"
+ github_locate_sha_patch "${input}" "${patchout}" "${diffout}"
;;
*)
- github_locate_pr_patch "${input}" "${output}"
+ github_locate_pr_patch "${input}" "${patchout}" "${diffout}"
;;
esac
}
diff --git a/precommit/src/main/shell/test-patch.d/gitlab.sh b/precommit/src/main/shell/test-patch.d/gitlab.sh
index 6e86792..e9f23ec 100755
--- a/precommit/src/main/shell/test-patch.d/gitlab.sh
+++ b/precommit/src/main/shell/test-patch.d/gitlab.sh
@@ -168,7 +168,8 @@ function gitlab_determine_branch
function gitlab_locate_mr_patch
{
declare input=$1
- declare output=$2
+ declare patchout=$2
+ declare diffout=$3
declare gitlabauth
input=${input#GL:}
@@ -202,7 +203,7 @@ function gitlab_locate_mr_patch
# with the assumption that this way binary files work.
# The downside of this is that the patch files are
# significantly larger and therefore take longer to process
- PATCHURL="${GITLAB_BASE_URL}/${GITLAB_REPO}/merge_requests/${input}.patch"
+ PATCHURL="${GITLAB_BASE_URL}/${GITLAB_REPO}/merge_requests/${input}"
echo "GITLAB MR #${input} is being downloaded at $(date) from"
echo "${GITLAB_BASE_URL}/${GITLAB_REPO}/merge_requests/${input}"
@@ -224,10 +225,20 @@ function gitlab_locate_mr_patch
# the actual patch file
if ! "${CURL}" --silent --fail \
- --output "${output}" \
+ --output "${patchout}" \
--location \
-H "${gitlabauth}" \
- "${PATCHURL}"; then
+ "${PATCHURL}.patch"; then
+ yetus_debug "gitlab_locate_patch: not a gitlab merge request."
+ return 1
+ fi
+
+ # the actual patch file
+ if ! "${CURL}" --silent --fail \
+ --output "${diffout}" \
+ --location \
+ -H "${gitlabauth}" \
+ "${PATCHURL}.diff"; then
yetus_debug "gitlab_locate_patch: not a gitlab merge request."
return 1
fi
@@ -254,7 +265,8 @@ function gitlab_locate_mr_patch
function gitlab_locate_sha_patch
{
declare input=$1
- declare output=$2
+ declare patchout=$2
+ declare diffout=$3
declare mrid
declare gitlabauth
@@ -295,7 +307,7 @@ function gitlab_locate_sha_patch
return 0
fi
- gitlab_locate_mr_patch "GL:${mrid}" "${output}"
+ gitlab_locate_mr_patch "GL:${mrid}" "${patchout}" "${diffout}"
}
## @description Handle the various ways to reference a gitlab MR
@@ -309,7 +321,8 @@ function gitlab_locate_sha_patch
function gitlab_locate_patch
{
declare input=$1
- declare output=$2
+ declare patchout=$2
+ declare diffout=$3
if [[ "${OFFLINE}" == true ]]; then
yetus_debug "gitlab_locate_patch: offline, skipping"
@@ -318,10 +331,10 @@ function gitlab_locate_patch
case "${input}" in
GLSHA:*)
- gitlab_locate_sha_patch "${input}" "${output}"
+ gitlab_locate_sha_patch "${input}" "${patchout}" "${diffout}"
;;
*)
- gitlab_locate_mr_patch "${input}" "${output}"
+ gitlab_locate_mr_patch "${input}" "${patchout}" "${diffout}"
;;
esac
}
diff --git a/precommit/src/main/shell/test-patch.d/jira.sh b/precommit/src/main/shell/test-patch.d/jira.sh
index cb2b53a..f8f4a2d 100755
--- a/precommit/src/main/shell/test-patch.d/jira.sh
+++ b/precommit/src/main/shell/test-patch.d/jira.sh
@@ -156,7 +156,8 @@ function jira_http_fetch
function jira_locate_patch
{
declare input=$1
- declare fileloc=$2
+ declare patchout=$2
+ declare diffout=$3
declare jsonloc
declare relativeurl
declare retval
@@ -183,7 +184,7 @@ function jira_locate_patch
jira_http_fetch "rest/api/2/issue/${input}" "${jsonloc}"
# Parse the downloaded information to check if the issue is
# just a pointer to GitHub.
- if github_jira_bridge "${fileloc}" "${jsonloc}"; then
+ if github_jira_bridge "${jsonloc}" "${patchout}" "${diffout}"; then
echo "${input} appears to be a Github PR. Switching Modes."
return 0
fi
@@ -219,7 +220,7 @@ function jira_locate_patch
printf " %s -> " "${PATCHURL}"
- jira_http_fetch "${relativeurl}" "${fileloc}"
+ jira_http_fetch "${relativeurl}" "${patchout}"
retval=$?
if [[ ${retval} == 0 ]]; then
found=true
@@ -239,7 +240,7 @@ function jira_locate_patch
fi
if [[ ! ${PATCHURL} =~ \.patch$ ]]; then
- if guess_patch_file "${fileloc}"; then
+ if guess_patch_file "${patchout}"; then
yetus_debug "The patch ${PATCHURL} was not named properly, but it looks like a patch file. Proceeding, but issue/branch matching might go awry."
add_vote_table 0 patch "The patch file was not named according to ${PROJECT_NAME}'s naming conventions. Please see ${PATCH_NAMING_RULE} for instructions."
else
diff --git a/precommit/src/main/shell/test-patch.sh b/precommit/src/main/shell/test-patch.sh
index 124dde1..f47b4e1 100755
--- a/precommit/src/main/shell/test-patch.sh
+++ b/precommit/src/main/shell/test-patch.sh
@@ -175,23 +175,6 @@ function offset_clock
fi
}
-## @description generate a stack trace when in debug mode
-## @audience public
-## @stability stable
-## @replaceable no
-## @return exits
-function generate_stack
-{
- declare -i frame
-
- frame=0
-
- while caller "${frame}"; do
- ((frame++));
- done
- exit 1
-}
-
## @description Add to the header of the display
## @audience public
## @stability stable
@@ -1371,7 +1354,7 @@ function determine_needed_tests
add_footer_table "Optional Tests" "${NEEDED_TESTS[*]}"
}
-## @description Given ${PATCH_DIR}/patch, apply the patch
+## @description Given ${INPUT_APPLIED_FILE}, actually apply the patch
## @audience private
## @stability evolving
## @replaceable no
@@ -1379,9 +1362,16 @@ function determine_needed_tests
## @return exit on failure
function apply_patch_file
{
- big_console_header "Applying patch to ${PATCH_BRANCH}"
- if ! patchfile_apply_driver "${PATCH_DIR}/patch"; then
+ if [[ "${INPUT_APPLIED_FILE}" == "${INPUT_DIFF_FILE}" ]]; then
+ BUGLINECOMMENTS=""
+ add_vote_table '-0' patch "Used diff version of patch file. Binary files and potentially other changes not applied. Please rebase and squash commits if necessary."
+ big_console_header "Applying diff to ${PATCH_BRANCH}"
+ else
+ big_console_header "Applying patch to ${PATCH_BRANCH}"
+ fi
+
+ if ! patchfile_apply_driver "${INPUT_APPLIED_FILE}"; then
echo "PATCH APPLICATION FAILED"
((RESULT = RESULT + 1))
add_vote_table -1 patch "${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}. Rebase required? Wrong Branch? See ${PATCH_NAMING_RULE} for help."
@@ -2886,7 +2876,7 @@ function patchfiletests
for plugin in ${BUILDTOOL} "${TESTTYPES[@]}" "${TESTFORMATS[@]}"; do
if declare -f "${plugin}_patchfile" >/dev/null 2>&1; then
yetus_debug "Running ${plugin}_patchfile"
- if ! "${plugin}_patchfile" "${PATCH_DIR}/patch"; then
+ if ! "${plugin}_patchfile" "${INPUT_APPLIED_FILE}"; then
((result = result+1))
fi
archive
@@ -2983,6 +2973,38 @@ function stop_coprocessors
fi
}
+## @description Additional setup work when in patch mode, including
+## @description setting ${INPUT_APPLIED_FILE} so that the system knows
+## @description which one to use because it will have passed dryrun.
+## @audience private
+## @stability evolving
+## @replaceable no
+function patch_setup_work
+{
+
+ # from here on out, we'll be in ${BASEDIR} for cwd
+ # plugins need to pushd/popd if they change.
+ git_checkout
+
+ determine_issue
+
+ if ! dryrun_both_files; then
+ ((RESULT = RESULT + 1))
+ yetus_error "ERROR: ${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}."
+ add_vote_table -1 patch "${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}. Rebase required? Wrong Branch? See ${PATCH_NAMING_RULE} for help."
+ bugsystem_finalreport 1
+ cleanup_and_exit 1
+ fi
+
+ if [[ "${ISSUE}" == 'Unknown' ]]; then
+ echo ""
+ echo "Testing ${INPUT_APPLY_TYPE} on ${PATCH_BRANCH}."
+ else
+ echo ""
+ echo "Testing ${ISSUE} ${INPUT_APPLY_TYPE} on ${PATCH_BRANCH}."
+ fi
+}
+
## @description Setup to execute
## @audience public
## @stability evolving
@@ -3044,29 +3066,10 @@ function initialize
locate_patch
fi
+ git_checkout
- # locate_patch might have changed our minds
- if [[ "${BUILDMODE}" = full ]]; then
- git_checkout
- else
- # from here on out, we'll be in ${BASEDIR} for cwd
- # plugins need to pushd/popd if they change.
- git_checkout
-
- determine_issue
- if [[ "${ISSUE}" == 'Unknown' ]]; then
- echo "Testing patch on ${PATCH_BRANCH}."
- else
- echo "Testing ${ISSUE} patch on ${PATCH_BRANCH}."
- fi
-
- if ! patchfile_dryrun_driver "${PATCH_DIR}/patch"; then
- ((RESULT = RESULT + 1))
- yetus_error "ERROR: ${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}."
- add_vote_table -1 patch "${PATCH_OR_ISSUE} does not apply to ${PATCH_BRANCH}. Rebase required? Wrong Branch? See ${PATCH_NAMING_RULE} for help."
- bugsystem_finalreport 1
- cleanup_and_exit 1
- fi
+ if [[ "${BUILDMODE}" = patch ]]; then
+ patch_setup_work
fi
find_changed_files