Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions precommit/src/main/shell/core.d/01-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@
delete_parameter "${i}"
PATCH=${i#*=}
;;
--patch-mode=*)
delete_parameter "${i}"
PATCH_MODE=${i#*=}

Check failure on line 206 in precommit/src/main/shell/core.d/01-common.sh

View workflow job for this annotation

GitHub Actions / build

shellcheck: warning: PATCH_MODE appears unused. Verify use (or export if used externally). [SC2034]

Check failure on line 206 in precommit/src/main/shell/core.d/01-common.sh

View workflow job for this annotation

GitHub Actions / build

shellcheck: warning: PATCH_MODE appears unused. Verify use (or export if used externally). [SC2034]
;;
--patch-dir=*)
delete_parameter "${i}"
PATCH_DIR=${i#*=}
Expand Down
39 changes: 28 additions & 11 deletions precommit/src/main/shell/core.d/patchfiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ PATCH_METHOD=""
PATCH_METHODS=("gitapply" "patchcmd")
PATCH_LEVEL=0
PATCH_HINT=""
PATCH_MODE="diff"

## @description Use curl to download the patch as a last resort
## @audience private
Expand Down Expand Up @@ -340,23 +341,39 @@ function patchfile_dryrun_driver
return 1
}

## @description dryrun both PATCH and DIFF and determine which one to use
## @description dryrun both PATCH and DIFF and determine which one to use.
## @description PATCH_MODE controls try-order: "diff" (default) avoids stale-file
## @description bugs from per-commit .patch stanzas (YETUS-983); "patch" restores
## @description the pre-YETUS-983 behavior for repos that need it.
## @replaceable no
## @audience private
## @stability evolving
function dryrun_both_files
{
# prefer the cumulative diff: it represents the PR's net change and avoids
# stale-file bugs when per-commit .patch stanzas add then rename/delete files
# (YETUS-983). Binary files are preserved when the diff is generated locally
# with --binary.
if [[ -f "${INPUT_DIFF_FILE}" ]] && patchfile_dryrun_driver "${INPUT_DIFF_FILE}"; then
INPUT_APPLY_TYPE="diff"
INPUT_APPLIED_FILE="${INPUT_DIFF_FILE}"
declare first_file
declare first_type
declare second_file
declare second_type

if [[ "${PATCH_MODE}" == "patch" ]]; then
first_file="${INPUT_PATCH_FILE}"
first_type="patch"
second_file="${INPUT_DIFF_FILE}"
second_type="diff"
else
first_file="${INPUT_DIFF_FILE}"
first_type="diff"
second_file="${INPUT_PATCH_FILE}"
second_type="patch"
fi

if [[ -f "${first_file}" ]] && patchfile_dryrun_driver "${first_file}"; then
INPUT_APPLY_TYPE="${first_type}"
INPUT_APPLIED_FILE="${first_file}"
return 0
elif [[ -f "${INPUT_PATCH_FILE}" ]] && patchfile_dryrun_driver "${INPUT_PATCH_FILE}"; then
INPUT_APPLY_TYPE="patch"
INPUT_APPLIED_FILE="${INPUT_PATCH_FILE}"
elif [[ -f "${second_file}" ]] && patchfile_dryrun_driver "${second_file}"; then
INPUT_APPLY_TYPE="${second_type}"
INPUT_APPLIED_FILE="${second_file}"
return 0
else
return 1
Expand Down
1 change: 1 addition & 0 deletions precommit/src/main/shell/test-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ function yetus_usage
yetus_add_option "--multijdktests=<list>" "Comma delimited tests to use when multijdkdirs is used. (default: '${jdktlist}')"
yetus_add_option "--offline" "Avoid connecting to the network"
yetus_add_option "--patch-dir=<dir>" "The directory for working and output files (default '/tmp/test-patch-${PROJECT_NAME}/pid')"
yetus_add_option "--patch-mode=<diff|patch>" "Try cumulative diff or per-commit patch first (default: '${PATCH_MODE}')"
yetus_add_option "--personality=<file>" "The personality file to load"
yetus_add_option "--plugins=<list>" "Specify which plug-ins to add/delete (comma delimited; use 'all' for all found) e.g. --plugins=all,-ant,-scalac (all plugins except ant and scalac)"
yetus_add_option "--proclimit=<num>" "Limit on the number of processes (default: ${PROC_LIMIT})"
Expand Down
Loading