You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by aw...@apache.org on 2015/08/03 20:03:26 UTC

[1/2] hadoop git commit: HADOOP-12121. smarter branch detection (aw)

Repository: hadoop
Updated Branches:
  refs/heads/HADOOP-12111 81c937426 -> 9a3596a26


HADOOP-12121. smarter branch detection (aw)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/595c7246
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/595c7246
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/595c7246

Branch: refs/heads/HADOOP-12111
Commit: 595c724689ca982681dd1d9cb029c2d78b22b447
Parents: 81c9374
Author: Allen Wittenauer <aw...@apache.org>
Authored: Mon Aug 3 10:47:11 2015 -0700
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Mon Aug 3 10:47:11 2015 -0700

----------------------------------------------------------------------
 dev-support/test-patch.sh | 160 ++++++++++++++++++++++++-----------------
 1 file changed, 94 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/595c7246/dev-support/test-patch.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.sh b/dev-support/test-patch.sh
index 48f83a0..1f1f88e 100755
--- a/dev-support/test-patch.sh
+++ b/dev-support/test-patch.sh
@@ -1281,9 +1281,6 @@ function git_checkout
     fi
 
     determine_branch
-    if [[ ${PATCH_BRANCH} =~ ^git ]]; then
-      PATCH_BRANCH=$(echo "${PATCH_BRANCH}" | cut -dt -f2)
-    fi
 
     # we need to explicitly fetch in case the
     # git ref hasn't been brought in tree yet
@@ -1322,9 +1319,6 @@ function git_checkout
     fi
 
     determine_branch
-    if [[ ${PATCH_BRANCH} =~ ^git ]]; then
-      PATCH_BRANCH=$(echo "${PATCH_BRANCH}" | cut -dt -f2)
-    fi
 
     currentbranch=$(${GIT} rev-parse --abbrev-ref HEAD)
     if [[ "${currentbranch}" != "${PATCH_BRANCH}" ]];then
@@ -1351,20 +1345,19 @@ function git_checkout
   return 0
 }
 
-## @description  Confirm the given branch is a member of the list of space
-## @description  delimited branches or a git ref
+## @description  Confirm the given branch is a git reference
+## @descriptoin  or a valid gitXYZ commit hash
 ## @audience     private
 ## @stability    evolving
 ## @replaceable  no
 ## @param        branch
-## @param        branchlist
-## @return       0 on success
+## @return       0 on success, if gitXYZ was passed, PATCH_BRANCH=xyz
 ## @return       1 on failure
 function verify_valid_branch
 {
-  local branches=$1
-  local check=$2
+  local check=$1
   local i
+  local hash
 
   # shortcut some common
   # non-resolvable names
@@ -1372,26 +1365,22 @@ function verify_valid_branch
     return 1
   fi
 
-  if [[ ${check} == patch ]]; then
-    return 1
-  fi
-
   if [[ ${check} =~ ^git ]]; then
-    ref=$(echo "${check}" | cut -f2 -dt)
-    count=$(echo "${ref}" | wc -c | tr -d ' ')
-
-    if [[ ${count} == 8 || ${count} == 41 ]]; then
-      return 0
+    hash=$(echo "${check}" | cut -f2- -dt)
+    if [[ -n ${hash} ]]; then
+      ${GIT} cat-file -t "${hash}" >/dev/null 2>&1
+      if [[ $? -eq 0 ]]; then
+        PATCH_BRANCH=${hash}
+        return 0
+      fi
+      return 1
+    else
+      return 1
     fi
-    return 1
   fi
 
-  for i in ${branches}; do
-    if [[ "${i}" == "${check}" ]]; then
-      return 0
-    fi
-  done
-  return 1
+  ${GIT} show-ref "${check}" >/dev/null 2>&1
+  return $?
 }
 
 ## @description  Try to guess the branch being tested using a variety of heuristics
@@ -1402,10 +1391,9 @@ function verify_valid_branch
 ## @return       1 on failure, with PATCH_BRANCH updated to PATCH_BRANCH_DEFAULT
 function determine_branch
 {
-  local allbranches
   local patchnamechunk
-
-  yetus_debug "Determine branch"
+  local total
+  local count
 
   # something has already set this, so move on
   if [[ -n ${PATCH_BRANCH} ]]; then
@@ -1414,6 +1402,13 @@ function determine_branch
 
   pushd "${BASEDIR}" > /dev/null
 
+  yetus_debug "Determine branch"
+
+  # something has already set this, so move on
+  if [[ -n ${PATCH_BRANCH} ]]; then
+    return
+  fi
+
   # developer mode, existing checkout, whatever
   if [[ "${DIRTY_WORKSPACE}" == true ]];then
     PATCH_BRANCH=$(${GIT} rev-parse --abbrev-ref HEAD)
@@ -1421,50 +1416,83 @@ function determine_branch
     return
   fi
 
-  allbranches=$(${GIT} branch -r | tr -d ' ' | ${SED} -e s,origin/,,g)
-
   for j in "${PATCHURL}" "${PATCH_OR_ISSUE}"; do
-    yetus_debug "Determine branch: starting with ${j}"
-    # shellcheck disable=SC2016
-    patchnamechunk=$(echo "${j}" | ${AWK} -F/ '{print $NF}')
-
-    # ISSUE.branch.##.patch
-    yetus_debug "Determine branch: ISSUE.branch.##.patch"
-    PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f2 -d. )
-    verify_valid_branch "${allbranches}" "${PATCH_BRANCH}"
-    if [[ $? == 0 ]]; then
-      return
+    if [[ -z "${j}" ]]; then
+      continue
     fi
-
-    # ISSUE-branch-##.patch
-    yetus_debug "Determine branch: ISSUE-branch-##.patch"
+    yetus_debug "Determine branch: starting with ${j}"
+    patchnamechunk=$(echo "${j}" \
+            | ${SED} -e 's,.*/\(.*\)$,\1,' \
+                     -e 's,\.txt,.,' \
+                     -e 's,.patch,.,g' \
+                     -e 's,.diff,.,g' \
+                     -e 's,\.\.,.,g' \
+                     -e 's,\.$,,g' )
+
+    # ISSUE-branch-##
     PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | cut -f1,2 -d-)
-    verify_valid_branch "${allbranches}" "${PATCH_BRANCH}"
-    if [[ $? == 0 ]]; then
-      return
+    yetus_debug "Determine branch: ISSUE-branch-## = ${PATCH_BRANCH}"
+    if [[ -n "${PATCH_BRANCH}" ]]; then
+      verify_valid_branch  "${PATCH_BRANCH}"
+      if [[ $? == 0 ]]; then
+        return
+      fi
     fi
 
-    # ISSUE-##.patch.branch
-    yetus_debug "Determine branch: ISSUE-##.patch.branch"
-    # shellcheck disable=SC2016
-    PATCH_BRANCH=$(echo "${patchnamechunk}" | ${AWK} -F. '{print $NF}')
-    verify_valid_branch "${allbranches}" "${PATCH_BRANCH}"
-    if [[ $? == 0 ]]; then
-      return
-    fi
+    # ISSUE-##[.##].branch
+    PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d. )
+    count="${PATCH_BRANCH//[^.]}"
+    total=${#count}
+    ((total = total + 3 ))
+    until [[ ${total} -eq 2 ]]; do
+      PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3-${total} -d.)
+      yetus_debug "Determine branch: ISSUE[.##].branch = ${PATCH_BRANCH}"
+      ((total=total-1))
+      if [[ -n "${PATCH_BRANCH}" ]]; then
+        verify_valid_branch  "${PATCH_BRANCH}"
+        if [[ $? == 0 ]]; then
+          return
+        fi
+      fi
+    done
+
+    # ISSUE.branch.##
+    PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f2- -d. )
+    count="${PATCH_BRANCH//[^.]}"
+    total=${#count}
+    ((total = total + 3 ))
+    until [[ ${total} -eq 2 ]]; do
+      PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f2-${total} -d.)
+      yetus_debug "Determine branch: ISSUE.branch[.##] = ${PATCH_BRANCH}"
+      ((total=total-1))
+      if [[ -n "${PATCH_BRANCH}" ]]; then
+        verify_valid_branch  "${PATCH_BRANCH}"
+        if [[ $? == 0 ]]; then
+          return
+        fi
+      fi
+    done
+
+    # ISSUE-branch.##
+    PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | cut -f1- -d. )
+    count="${PATCH_BRANCH//[^.]}"
+    total=${#count}
+    ((total = total + 1 ))
+    until [[ ${total} -eq 1 ]]; do
+      PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | cut -f1-${total} -d. )
+      yetus_debug "Determine branch: ISSUE-branch[.##] = ${PATCH_BRANCH}"
+      ((total=total-1))
+      if [[ -n "${PATCH_BRANCH}" ]]; then
+        verify_valid_branch  "${PATCH_BRANCH}"
+        if [[ $? == 0 ]]; then
+          return
+        fi
+      fi
+    done
 
-    # ISSUE-branch.##.patch
-    yetus_debug "Determine branch: ISSUE-branch.##.patch"
-    # shellcheck disable=SC2016
-    PATCH_BRANCH=$(echo "${patchnamechunk}" | cut -f3- -d- | ${AWK} -F. '{print $(NF-2)}' 2>/dev/null)
-    verify_valid_branch "${allbranches}" "${PATCH_BRANCH}"
-    if [[ $? == 0 ]]; then
-      return
-    fi
   done
 
   PATCH_BRANCH="${PATCH_BRANCH_DEFAULT}"
-
   popd >/dev/null
 }
 


[2/2] hadoop git commit: add missing files from previous commits because I can never remember to do a git add

Posted by aw...@apache.org.
add missing files from previous commits because I can never remember to do a git add


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/9a3596a2
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/9a3596a2
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/9a3596a2

Branch: refs/heads/HADOOP-12111
Commit: 9a3596a26c024b6576fc3ce40d19054bfe12baa2
Parents: 595c724
Author: Allen Wittenauer <aw...@apache.org>
Authored: Mon Aug 3 11:03:18 2015 -0700
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Mon Aug 3 11:03:18 2015 -0700

----------------------------------------------------------------------
 dev-support/test-patch.d/perlcritic.sh | 140 ++++++++++++++++++++++++++++
 dev-support/test-patch.d/ruby-lint.sh  | 140 ++++++++++++++++++++++++++++
 2 files changed, 280 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/9a3596a2/dev-support/test-patch.d/perlcritic.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/perlcritic.sh b/dev-support/test-patch.d/perlcritic.sh
new file mode 100755
index 0000000..1cec3f3
--- /dev/null
+++ b/dev-support/test-patch.d/perlcritic.sh
@@ -0,0 +1,140 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_plugin perlcritic
+
+PERLCRITIC_TIMER=0
+
+PERLCRITIC=${PERLCRITIC:-$(which perlcritic 2>/dev/null)}
+
+function perlcritic_usage
+{
+  echo "Perl::Critic specific:"
+  echo "--perlcritic=<path> path to perlcritic executable"
+}
+
+function perlcritic_parse_args
+{
+  local i
+
+  for i in "$@"; do
+    case ${i} in
+    --perlcritic=*)
+      PERLCRITIC=${i#*=}
+    ;;
+    esac
+  done
+}
+
+function perlcritic_filefilter
+{
+  local filename=$1
+
+  if [[ ${filename} =~ \.p[lm]$ ]]; then
+    add_test perlcritic
+  fi
+}
+
+function perlcritic_preapply
+{
+  local i
+
+  verify_needed_test perlcritic
+  if [[ $? == 0 ]]; then
+    return 0
+  fi
+
+  big_console_header "Perl::Critic plugin: prepatch"
+
+  if [[ ! -x ${PERLCRITIC} ]]; then
+    yetus_error "${PERLCRITIC} does not exist."
+    return 0
+  fi
+
+  start_clock
+
+  echo "Running perlcritic against modified perl scripts/modules."
+  pushd "${BASEDIR}" >/dev/null
+  for i in ${CHANGED_FILES}; do
+    if [[ ${i} =~ \.p[lm]$ && -f ${i} ]]; then
+      ${PERLCRITIC} -1 --verbose 1 "${i}" 2>/dev/null >> "${PATCH_DIR}/branch-perlcritic-result.txt"
+    fi
+  done
+  popd >/dev/null
+  # keep track of how much as elapsed for us already
+  PERLCRITIC_TIMER=$(stop_clock)
+  return 0
+}
+
+function perlcritic_postapply
+{
+  local i
+  local numPrepatch
+  local numPostpatch
+  local diffPostpatch
+
+  verify_needed_test perlcritic
+  if [[ $? == 0 ]]; then
+    return 0
+  fi
+
+  big_console_header "Perl::Critic plugin: postpatch"
+
+  if [[ ! -x ${PERLCRITIC} ]]; then
+    yetus_error "${PERLCRITIC} is not available."
+    add_vote_table 0 perlcritic "Perl::Critic was not available."
+    return 0
+  fi
+
+  start_clock
+
+  # add our previous elapsed to our new timer
+  # by setting the clock back
+  offset_clock "${PERLCRITIC_TIMER}"
+
+  echo "Running perlcritic against modified perl scripts/modules."
+  # we re-check this in case one has been added
+  pushd "${BASEDIR}" >/dev/null
+  for i in ${CHANGED_FILES}; do
+    if [[ ${i} =~ \.p[lm]$ && -f ${i} ]]; then
+      ${PERLCRITIC} -1 --verbose 1 "${i}" 2>/dev/null >> "${PATCH_DIR}/patch-perlcritic-result.txt"
+    fi
+  done
+  popd >/dev/null
+
+  PERLCRITIC_VERSION=$(${PERLCRITIC} --version 2>/dev/null)
+  add_footer_table perlcritic "v${PERLCRITIC_VERSION}"
+
+  calcdiffs "${PATCH_DIR}/branch-perlcritic-result.txt" "${PATCH_DIR}/patch-perlcritic-result.txt" > "${PATCH_DIR}/diff-patch-perlcritic.txt"
+  # shellcheck disable=SC2016
+  diffPostpatch=$(wc -l "${PATCH_DIR}/diff-patch-perlcritic.txt" | ${AWK} '{print $1}')
+
+  if [[ ${diffPostpatch} -gt 0 ]] ; then
+    # shellcheck disable=SC2016
+    numPrepatch=$(wc -l "${PATCH_DIR}/branch-perlcritic-result.txt" | ${AWK} '{print $1}')
+
+    # shellcheck disable=SC2016
+    numPostpatch=$(wc -l "${PATCH_DIR}/patch-perlcritic-result.txt" | ${AWK} '{print $1}')
+
+    add_vote_table -1 perlcritic "The applied patch generated "\
+      "${diffPostpatch} new Perl::Critic issues (total was ${numPrepatch}, now ${numPostpatch})."
+    add_footer_table perlcritic "@@BASE@@/diff-patch-perlcritic.txt"
+    return 1
+  fi
+
+  add_vote_table +1 perlcritic "There were no new perlcritic issues."
+  return 0
+}

http://git-wip-us.apache.org/repos/asf/hadoop/blob/9a3596a2/dev-support/test-patch.d/ruby-lint.sh
----------------------------------------------------------------------
diff --git a/dev-support/test-patch.d/ruby-lint.sh b/dev-support/test-patch.d/ruby-lint.sh
new file mode 100755
index 0000000..35d9604
--- /dev/null
+++ b/dev-support/test-patch.d/ruby-lint.sh
@@ -0,0 +1,140 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_plugin ruby_lint
+
+RUBY_LINT_TIMER=0
+
+RUBY_LINT=${RUBY_LINT:-$(which ruby-lint 2>/dev/null)}
+
+function ruby_lint_usage
+{
+  echo "Ruby-lint specific:"
+  echo "--ruby-lint=<path> path to ruby-lint executable"
+}
+
+function ruby_lint_parse_args
+{
+  local i
+
+  for i in "$@"; do
+    case ${i} in
+    --ruby-lint=*)
+      RUBY_LINT=${i#*=}
+    ;;
+    esac
+  done
+}
+
+function ruby_lint_filefilter
+{
+  local filename=$1
+
+  if [[ ${filename} =~ \.rb$ ]]; then
+    add_test ruby_lint
+  fi
+}
+
+function ruby_lint_preapply
+{
+  local i
+
+  verify_needed_test ruby_lint
+  if [[ $? == 0 ]]; then
+    return 0
+  fi
+
+  big_console_header "ruby-lint plugin: prepatch"
+
+  if [[ ! -x ${RUBY_LINT} ]]; then
+    yetus_error "${RUBY_LINT} does not exist."
+    return 0
+  fi
+
+  start_clock
+
+  echo "Running ruby-lint against modified ruby scripts."
+  pushd "${BASEDIR}" >/dev/null
+  for i in ${CHANGED_FILES}; do
+    if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
+      ${RUBY_LINT} -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/branch-ruby-lint-result.txt"
+    fi
+  done
+  popd >/dev/null
+  # keep track of how much as elapsed for us already
+  RUBY_LINT_TIMER=$(stop_clock)
+  return 0
+}
+
+function ruby_lint_postapply
+{
+  local i
+  local numPrepatch
+  local numPostpatch
+  local diffPostpatch
+
+  verify_needed_test ruby_lint
+  if [[ $? == 0 ]]; then
+    return 0
+  fi
+
+  big_console_header "ruby-lint plugin: postpatch"
+
+  if [[ ! -x ${RUBY_LINT} ]]; then
+    yetus_error "${RUBY_LINT} is not available."
+    add_vote_table 0 ruby-lint "Ruby-lint was not available."
+    return 0
+  fi
+
+  start_clock
+
+  # add our previous elapsed to our new timer
+  # by setting the clock back
+  offset_clock "${RUBY_LINT_TIMER}"
+
+  echo "Running ruby-lint against modified ruby scripts."
+  # we re-check this in case one has been added
+  pushd "${BASEDIR}" >/dev/null
+  for i in ${CHANGED_FILES}; do
+    if [[ ${i} =~ \.rb$ && -f ${i} ]]; then
+      ${RUBY_LINT} -p syntastic "${i}" | sort -t : -k 1,1 -k 3,3n -k 4,4n >> "${PATCH_DIR}/patch-ruby-lint-result.txt"
+    fi
+  done
+  popd >/dev/null
+
+  # shellcheck disable=SC2016
+  RUBY_LINT_VERSION=$(${RUBY_LINT} -v | ${AWK} '{print $2}')
+  add_footer_table ruby-lint "${RUBY_LINT_VERSION}"
+
+  calcdiffs "${PATCH_DIR}/branch-ruby-lint-result.txt" "${PATCH_DIR}/patch-ruby-lint-result.txt" > "${PATCH_DIR}/diff-patch-ruby-lint.txt"
+  diffPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/diff-patch-ruby-lint.txt")
+
+  if [[ ${diffPostpatch} -gt 0 ]] ; then
+    # shellcheck disable=SC2016
+    numPrepatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/branch-ruby-lint-result.txt")
+
+    # shellcheck disable=SC2016
+    numPostpatch=$(${AWK} -F: 'BEGIN {sum=0} 4<NF {sum+=1} END {print sum}' "${PATCH_DIR}/patch-ruby-lint-result.txt")
+
+    add_vote_table -1 ruby-lint "The applied patch generated "\
+      "${diffPostpatch} new ruby-lint issues (total was ${numPrepatch}, now ${numPostpatch})."
+    add_footer_table ruby-lint "@@BASE@@/diff-patch-ruby-lint.txt"
+    return 1
+  fi
+
+  add_vote_table +1 ruby-lint "There were no new ruby-lint issues."
+  return 0
+}