Repository: hive
Updated Branches:
  refs/heads/master f5e62eb03 -> 14b972e96


HIVE-20191: PreCommit patch application doesn't fail if patch is empty (Daniel 
Voros via Zoltan Haindrich, Vihang Karajgaonkar)

Signed-off-by: Zoltan Haindrich <k...@rxd.hu>


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/14b972e9
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/14b972e9
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/14b972e9

Branch: refs/heads/master
Commit: 14b972e964b1fed49c962949e1b0119ebf441bb1
Parents: 826e553
Author: Daniel Voros <daniel.vo...@gmail.com>
Authored: Mon Aug 27 11:07:36 2018 +0200
Committer: Zoltan Haindrich <k...@rxd.hu>
Committed: Mon Aug 27 11:53:49 2018 +0200

----------------------------------------------------------------------
 dev-support/jenkins-common.sh                   | 35 +++++++++++++++++---
 .../src/main/resources/smart-apply-patch.sh     |  9 ++++-
 2 files changed, 38 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/14b972e9/dev-support/jenkins-common.sh
----------------------------------------------------------------------
diff --git a/dev-support/jenkins-common.sh b/dev-support/jenkins-common.sh
index 0467d11..4edf398 100644
--- a/dev-support/jenkins-common.sh
+++ b/dev-support/jenkins-common.sh
@@ -31,12 +31,9 @@ get_branch_name() {
   local branch="$2"        # $2 is a default branch
 
   if [[ -n $PATCH_NAME ]]; then
-    # Test PATCH_NAME:
-    # HIVE-123.patch HIVE-123.1.patch HIVE-123-tez.patch HIVE-123.1-tez.patch
-    # HIVE-XXXX.patch, HIVE-XXXX.XX.patch  HIVE-XXXX.XX-branch.patch 
HIVE-XXXX-branch.patch
-    if [[ $PATCH_NAME =~ 
^HIVE-[0-9]+(\.[0-9]+)?(-[A-Za-z0-9.-]+)?\.(patch|patch.\txt)$ ]]; then
+    if [[ $PATCH_NAME =~ 
^HIVE-[0-9]+(\.[0-9]+)?([-\.][A-Za-z0-9.-]+)?\.(patch|patch.\txt)$ ]]; then
       if [[ -n "${BASH_REMATCH[2]}" ]]; then
-        branch=${BASH_REMATCH[2]#*-}
+        branch=${BASH_REMATCH[2]:1}
       fi
     elif [[ $PATCH_NAME =~ 
^(HIVE-[0-9]+\.)?D[0-9]+(\.[0-9]+)?\.(patch|patch.\txt)$ ]]; then
       # It will assume the default branch
@@ -51,6 +48,34 @@ get_branch_name() {
   return 0
 }
 
+# Used during development for testing get_branch_name
+_test_get_branch_name() {
+  do_test() {
+    local PATCH_NAME="$1"
+    local EXPECTED="$2"
+
+    local ACTUAL=$(get_branch_name $PATCH_NAME master)
+
+    [[ "$ACTUAL" == "$EXPECTED" ]] || echoerr "$PATCH_NAME failed ($ACTUAL != 
$EXPECTED)"
+  }
+
+  # Branch not spcified in patch name
+  do_test "HIVE-123.patch" "master"
+  do_test "HIVE-123.1.patch" "master"
+
+  # Branch name separated by '-'
+  do_test "HIVE-123-tez.patch" "tez"
+  do_test "HIVE-123.1-tez.patch" "tez"
+  do_test "HIVE-123-branch-2.patch" "branch-2"
+  do_test "HIVE-123.1-branch-2.patch" "branch-2"
+
+  # Branch name separated by '.'
+  do_test "HIVE-123.tez.patch" "tez"
+  do_test "HIVE-123.1.tez.patch" "tez"
+  do_test "HIVE-123.branch-2.patch" "branch-2"
+  do_test "HIVE-123.1.branch-2.patch" "branch-2"
+}
+
 # Gets the attachment identifier of a JIRA attachment file
 get_attachment_id() {
   local jira_attachment_url="$1"

http://git-wip-us.apache.org/repos/asf/hive/blob/14b972e9/testutils/ptest2/src/main/resources/smart-apply-patch.sh
----------------------------------------------------------------------
diff --git a/testutils/ptest2/src/main/resources/smart-apply-patch.sh 
b/testutils/ptest2/src/main/resources/smart-apply-patch.sh
index 6f69083..b70eb86 100644
--- a/testutils/ptest2/src/main/resources/smart-apply-patch.sh
+++ b/testutils/ptest2/src/main/resources/smart-apply-patch.sh
@@ -90,5 +90,12 @@ fi
 
 echo Going to apply patch with: git apply -p$PLEVEL
 git apply -p$PLEVEL -3 $PATCH_FILE
+ret=$?
 
-cleanup $?
\ No newline at end of file
+# Fail if patch was empty
+if [[ -z $(git status --porcelain) ]]; then
+  echo "The patch had no effect. Was this change committed in another patch? 
Are you using the correct branch?"
+  cleanup 1
+fi
+
+cleanup $ret

Reply via email to