yetus-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [yetus] branch master updated: YETUS-868. Patch modifying the excludes file should force a re-read
Date Fri, 03 May 2019 14:33:17 GMT
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 0b4059d  YETUS-868. Patch modifying the excludes file should force a re-read
0b4059d is described below

commit 0b4059db386bdd1dd8cd1a8f83162a53c15e1ed3
Author: Allen Wittenauer <aw@apache.org>
AuthorDate: Tue Apr 30 10:44:13 2019 -0700

    YETUS-868. Patch modifying the excludes file should force a re-read
    
    Signed-off-by: Sean Busbey <busbey@apache.org>
---
 precommit/src/main/shell/core.d/change-analysis.sh |  5 ++
 .../shell/test-patch-docker/launch-test-patch.sh   |  4 --
 precommit/src/main/shell/test-patch.sh             | 66 +++++++++++++---------
 3 files changed, 44 insertions(+), 31 deletions(-)

diff --git a/precommit/src/main/shell/core.d/change-analysis.sh b/precommit/src/main/shell/core.d/change-analysis.sh
index 430139d..3c4f40e 100755
--- a/precommit/src/main/shell/core.d/change-analysis.sh
+++ b/precommit/src/main/shell/core.d/change-analysis.sh
@@ -90,10 +90,15 @@ function exclude_paths_from_changed_files
   declare strip
   declare -a a
 
+  EXCLUDE_PATHS=()
+
   if [[ -n "${EXCLUDE_PATHS_FILE}" ]]; then
     yetus_file_to_array EXCLUDE_PATHS "${EXCLUDE_PATHS_FILE}"
+  else
+    return
   fi
 
+  a=()
   for f in "${CHANGED_FILES[@]}"; do
     strip=false
     for p in "${EXCLUDE_PATHS[@]}"; do
diff --git a/precommit/src/main/shell/test-patch-docker/launch-test-patch.sh b/precommit/src/main/shell/test-patch-docker/launch-test-patch.sh
index e5b9f58..110d65f 100755
--- a/precommit/src/main/shell/test-patch-docker/launch-test-patch.sh
+++ b/precommit/src/main/shell/test-patch-docker/launch-test-patch.sh
@@ -54,10 +54,6 @@ PATCH_DIR=$(yetus_abs "${PATCH_DIR}")
 OVERWRITEARGS+=("--patch-dir=${PATCH_DIR}")
 OVERWRITEARGS+=("--user-plugins=${PATCH_DIR}/precommit/user-plugins")
 
-if [[ -f "${PATCH_DIR}/precommit/excluded.txt" ]]; then
-  OVERWRITEARGS+=("--excludes=${PATCH_DIR}/precommit/excluded.txt")
-fi
-
 if [[ -f "${PATCH_DIR}/precommit/unit_test_filter_file.txt" ]]; then
   OVERWRITEARGS+=("--unit-test-filter-file=${PATCH_DIR}/precommit/unit_test_filter_file.txt")
 fi
diff --git a/precommit/src/main/shell/test-patch.sh b/precommit/src/main/shell/test-patch.sh
index 259d362..d267e9c 100755
--- a/precommit/src/main/shell/test-patch.sh
+++ b/precommit/src/main/shell/test-patch.sh
@@ -483,7 +483,7 @@ function compute_gitdiff
   "${GIT}" add --all --intent-to-add
   while read -r line; do
     if [[ ${line} =~ ^\+\+\+ ]]; then
-      file="./"$(echo "${line}" | cut -f2- -d/)
+      file=$(echo "${line}" | cut -f2- -d/)
       continue
     elif [[ ${line} =~ ^@@ ]]; then
       startline=$(echo "${line}" | cut -f3 -d' ' | cut -f1 -d, | tr -d + )
@@ -531,8 +531,6 @@ function compute_gitdiff
 
   if [[ -s "${GITDIFFLINES}" ]]; then
     compute_unidiff
-  else
-    touch "${GITUNIDIFFLINES}"
   fi
 
   popd >/dev/null || return 1
@@ -558,33 +556,37 @@ function compute_unidiff
   # out the 'extra' lines, grabbing the adds with
   # the line number in the diff file along the way,
   # finally rewriting the line so that it is in
-  # './filename:diff line:content' format
+  # 'filename:diff line:content' format
 
   for fn in "${CHANGED_FILES[@]}"; do
-    filen=${fn##./}
-
     if [[ -f "${filen}" ]]; then
       "${GIT}" diff "${filen}" \
         | tail -n +6 \
         | "${GREP}" -n '^+' \
         | "${GREP}" -vE '^[0-9]*:\+\+\+' \
         | "${SED}" -e 's,^\([0-9]*:\)\+,\1,g' \
-          -e "s,^,./${filen}:,g" \
+          -e "s,^,${filen}:,g" \
               >>  "${tmpfile}"
     fi
   done
 
-  # at this point, tmpfile should be in the same format
-  # as gitdiffcontent, just with different line numbers.
-  # let's do a merge (using gitdifflines because it's easier)
+  # if every file that got changed was excluded, there
+  # is no data to calculate.
 
-  # ./filename:real number:diff number
-  # shellcheck disable=SC2016
-  paste -d: "${GITDIFFLINES}" "${tmpfile}" \
-    | "${AWK}" -F: '{print $1":"$2":"$5":"$6}' \
-    >> "${GITUNIDIFFLINES}"
+  if [[ -s "${tmpfile}" ]]; then
 
-  rm "${tmpfile}"
+    # at this point, tmpfile should be in the same format
+    # as gitdiffcontent, just with different line numbers.
+    # let's do a merge (using gitdifflines because it's easier)
+
+    # filename:real number:diff number
+    # shellcheck disable=SC2016
+    paste -d: "${GITDIFFLINES}" "${tmpfile}" \
+      | "${AWK}" -F: '{print $1":"$2":"$5":"$6}' \
+      >> "${GITUNIDIFFLINES}"
+
+    rm "${tmpfile}"
+  fi
 }
 
 
@@ -822,7 +824,7 @@ function parse_args
         DIRTY_WORKSPACE=true
       ;;
       --excludes=*)
-        EXCLUDE_PATHS_FILE=$(yetus_abs "${i#*=}")
+        EXCLUDE_PATHS_FILE="${i#*=}"
       ;;
       --instance=*)
         INSTANCE=${i#*=}
@@ -945,15 +947,6 @@ function parse_args
     yetus_add_array_element EXEC_MODES Robot
   fi
 
-  if [[ -n "${EXCLUDE_PATHS_FILE}" ]]; then
-    if [[ -f "${EXCLUDE_PATHS_FILE}" ]]; then
-      EXCLUDE_PATHS_FILE=$(yetus_abs "${EXCLUDE_PATHS_FILE}")
-    else
-      yetus_error "ERROR: Excluded paths file (${EXCLUDE_PATHS_FILE}}) does not exist!"
-      cleanup_and_exit 1
-    fi
-  fi
-
   if [[ -n $UNIT_TEST_FILTER_FILE ]]; then
     if [[ -f $UNIT_TEST_FILTER_FILE ]]; then
       UNIT_TEST_FILTER_FILE=$(yetus_abs "${UNIT_TEST_FILTER_FILE}")
@@ -1004,6 +997,19 @@ function parse_args
   PATCH_DIR=$(yetus_abs "${PATCH_DIR}")
   COPROC_LOGFILE="${PATCH_DIR}/coprocessors.txt"
 
+  if [[ -n "${EXCLUDE_PATHS_FILE}" ]]; then
+    if [[ -f "${EXCLUDE_PATHS_FILE}" ]]; then
+      EXCLUDE_PATHS_FILE=$(yetus_abs "${EXCLUDE_PATHS_FILE}")
+    elif [[ -f "${BASEDIR}/${EXCLUDE_PATHS_FILE}" ]]; then
+      EXCLUDE_PATHS_FILE=$(yetus_abs "${BASEDIR}/${EXCLUDE_PATHS_FILE}")
+    elif [[ -f "${PATCH_DIR}/precommit/excluded.txt" ]]; then
+       EXCLUDE_PATHS_FILE="${PATCH_DIR}/precommit/excluded.txt"
+    else
+      yetus_error "ERROR: Excluded paths file (${EXCLUDE_PATHS_FILE}}) does not exist!"
+      cleanup_and_exit 1
+    fi
+  fi
+
   # we need absolute dir for ${CONSOLE_REPORT_FILE}
   if [[ -n "${CONSOLE_REPORT_FILE}" ]]; then
     if : > "${CONSOLE_REPORT_FILE}"; then
@@ -2141,6 +2147,10 @@ function bugsystem_linecomments_writer
   declare idxline
   declare uniline
 
+  if [[ ! -f "${GITUNIDIFFLINES}" ]]; then
+    return
+  fi
+
   if [[ -z "${fn}" ]]; then
     return
   fi
@@ -2171,7 +2181,7 @@ function bugsystem_linecomments_trigger
   declare plugin
 
   if [[ ! -f "${GITUNIDIFFLINES}" ]]; then
-    return
+    return 0
   fi
 
   if [[ ! -f "${PATCH_DIR}/linecomments-in.txt" ]]; then
@@ -3190,6 +3200,8 @@ if [[ "${BUILDMODE}" = patch ]]; then
 
   apply_patch_file
 
+  exclude_paths_from_changed_files
+
   compute_gitdiff
 
   add_vote_table H "Patch Compile Tests"


Mime
View raw message