You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metron.apache.org by ottobackwards <gi...@git.apache.org> on 2018/10/26 17:54:36 UTC

[GitHub] metron pull request #1248: METRON-1847 break out functions from prepare-comm...

GitHub user ottobackwards opened a pull request:

    https://github.com/apache/metron/pull/1248

    METRON-1847 break out functions from prepare-commit for re-use

    This pr breaks out the prepare-commit script into a common script and a prepare-commit script.  This will allow re-use of that code for future scripts.
    
    Test by preparing..... commits for current PR's as is your fashion.  The script should work as before.
    
    ### For all changes:
    - [x] Is there a JIRA ticket associated with this PR? If not one needs to be created at [Metron Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel).
    - [x] Does your PR title start with METRON-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    - [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    
    ### For code changes:
    - [-] Have you included steps to reproduce the behavior or problem that is being changed or addressed?
    - [x] Have you included steps or a guide to how the change may be verified and tested manually?
    - [x] Have you ensured that the full suite of tests and checks have been executed in the root metron folder via:
      ```
      mvn -q clean integration-test install && dev-utilities/build-utils/verify_licenses.sh 
      ```
    
    - [-] Have you written or updated unit tests and or integration tests to verify your changes?
    - [-] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
    - [-] Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent?
    
    ### For documentation related changes:
    - [-] Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via `site-book/target/site/index.html`:
    
      ```
      cd site-book
      mvn site
      ```
    
    #### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
    It is also recommended that [travis-ci](https://travis-ci.org) is set up for your personal repository such that your branches are built there before submitting a pull request.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ottobackwards/metron script_functions

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/metron/pull/1248.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1248
    
----
commit bdc74efc5ac5b85989eb09ca76693e1e7c2cb0c4
Author: Otto Fowler <ot...@...>
Date:   2018-10-26T17:51:47Z

    METRON-1847 break out functions from prepare-commit for re-use

----


---

[GitHub] metron pull request #1248: METRON-1847 break out functions from prepare-comm...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1248#discussion_r228715383
  
    --- Diff: dev-utilities/committer-utils/prepare-commit ---
    @@ -16,242 +16,31 @@
     #  limitations under the License.
     #
     
    -# not likely to change
    -METRON_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron.git"
    -BRO_PLUGIN_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron-bro-plugin-kafka.git"
    -CONFIG_FILE=~/.metron-prepare-commit
    -GITHUB_REMOTE="origin"
    -BASE_BRANCH=master
    +LOCATION_DIR=`dirname $0`
    --- End diff --
    
    Why cd there?  how about
    LOCATION_DIR="$( dirname "${BASH_SOURCE[0]}"


---

[GitHub] metron pull request #1248: METRON-1847 break out functions from prepare-comm...

Posted by JonZeolla <gi...@git.apache.org>.
Github user JonZeolla commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1248#discussion_r228619906
  
    --- Diff: dev-utilities/committer-utils/metron-committer-common ---
    @@ -0,0 +1,353 @@
    +#!/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.
    +#
    +
    +#
    +# common and unlikely to change vars
    +#
    +
    +# the upstream apache git repo for apache metron
    +METRON_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron.git"
    +# the upstream apache git repo for apache metron bro plugin kafka
    +BRO_PLUGIN_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron-bro-plugin-kafka.git"
    +# the common configuration file with the committer info
    +CONFIG_FILE=~/.metron-prepare-commit
    +
    +GITHUB_REMOTE="origin"
    +BASE_BRANCH=master
    +
    +# other var setup by these functions
    +PR=
    +WORK=
    +ORIGIN=
    +UPSTREAM=
    +PR_BRANCH=
    +USER=
    +EMAIL=
    +JIRA=
    +DESC=
    +
    +#
    +# Initialize the variables from the default configuration file, if it exists
    +#
    +function init_configuration {
    +    # does a config file already exist?
    +    echo "$CONFIG_FILE"
    +    if [ -f ${CONFIG_FILE} ]; then
    +        source ${CONFIG_FILE}
    +        echo "  ...using settings from $CONFIG_FILE"
    +    fi
    +}
    +
    +
    +#
    +# Initialize the committer variables if it is not provided through the configuration file.
    +# If it is not present, it will be written out for the next time
    +#
    +function init_committer_info {
    +    # github account of committer (you)
    +    if [ -z "$GITHUB_NAME" ]; then
    +        read -p "  your github username [$GITHUB_NAME]: " INPUT
    +        [ -n "$INPUT" ] && GITHUB_NAME=${INPUT}
    +
    +        # write setting to config file
    +        echo "GITHUB_NAME=$GITHUB_NAME" >> ${CONFIG_FILE}
    +    fi
    +
    +    # apache id of committer (you)
    +    if [ -z "$APACHE_NAME" ]; then
    +      read -p "  your apache userid [$APACHE_NAME]: " INPUT
    +      [ -n "$INPUT" ] && APACHE_NAME=$INPUT
    +
    +      # write setting to config file
    +      echo "APACHE_NAME=$APACHE_NAME" >> ${CONFIG_FILE}
    +    fi
    +
    +    # apache email addr of committer (you)
    +    if [ -z "$APACHE_EMAIL" ]; then
    +      APACHE_EMAIL=${APACHE_NAME}@apache.org
    +      read -p "  your apache email [$APACHE_EMAIL]: " INPUT
    +      [ -n "$INPUT" ] && APACHE_EMAIL=${INPUT}
    +
    +      # write setting to config file, so it is not needed next time
    +      echo "APACHE_EMAIL=$APACHE_EMAIL" >> ${CONFIG_FILE}
    +    fi
    +}
    +
    +#
    +# Provide the user with a choice of the metron or bro repositories
    +#
    +function chose_metron_or_bro_repo {
    --- End diff --
    
    choose?


---

[GitHub] metron pull request #1248: METRON-1847 break out functions from prepare-comm...

Posted by JonZeolla <gi...@git.apache.org>.
Github user JonZeolla commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1248#discussion_r228614878
  
    --- Diff: dev-utilities/committer-utils/prepare-commit ---
    @@ -16,242 +16,31 @@
     #  limitations under the License.
     #
     
    -# not likely to change
    -METRON_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron.git"
    -BRO_PLUGIN_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron-bro-plugin-kafka.git"
    -CONFIG_FILE=~/.metron-prepare-commit
    -GITHUB_REMOTE="origin"
    -BASE_BRANCH=master
    +LOCATION_DIR=`dirname $0`
     
    -# does a config file already exist?
    -if [ -f $CONFIG_FILE ]; then
    -  . $CONFIG_FILE
    -  echo "  ...using settings from $CONFIG_FILE"
    -fi
    +source ${LOCATION_DIR}/metron-committer-common
     
    -# which repo?  metron or metron-bro-plugin-kafka
    -echo "    [1] metron"
    -echo "    [2] metron-bro-plugin-kafka"
    -read -p "  which repo? [1]: " INPUT
    -case "${INPUT}" in
    -  [Bb][Rr][Oo]|[Mm][Ee][Tt][Rr][Oo][Nn]-[Bb][Rr][Oo]-[Pp][Ll][Uu][Gg][Ii][Nn]-[Kk][Aa][Ff][Kk][Aa]|*metron-bro-plugin-kafka\.git|2)
    -    INPUT="${BRO_PLUGIN_UPSTREAM}" ;;
    -  [Mm][Ee][Tt][Rr][Oo][Nn]|*metron\.git|1|'')
    -    INPUT="${METRON_UPSTREAM}" ;;
    -  *)
    -    echo "Invalid repo, provided \"${INPUT}\".  Please choose between metron or metron-bro-plugin-kafka"
    -    exit 1
    -    ;;
    -esac
    -[ -n "$INPUT" ] && UPSTREAM=$INPUT
    +init_configuration
     
    -CHOSEN_REPO=$(basename ${UPSTREAM%%.git})
    +chose_metron_or_bro_repo
     
    -# github account of committer (you)
    -if [ -z "$GITHUB_NAME" ]; then
    -  read -p "  your github username [$GITHUB_NAME]: " INPUT
    -  [ -n "$INPUT" ] && GITHUB_NAME=$INPUT
    +init_committer_info
     
    -  # write setting to config file
    -  echo "GITHUB_NAME=$GITHUB_NAME" >> $CONFIG_FILE
    -fi
    +read_pull_request
     
    -# apache id of committer (you)
    -if [ -z "$APACHE_NAME" ]; then
    -  read -p "  your apache userid [$APACHE_NAME]: " INPUT
    -  [ -n "$INPUT" ] && APACHE_NAME=$INPUT
    +setup_working_directory ~/tmp/${CHOSEN_REPO}-pr${PR}
     
    -  # write setting to config file
    -  echo "APACHE_NAME=$APACHE_NAME" >> $CONFIG_FILE
    -fi
    +setup_code{CHOSEN_REPO}
     
    -# apache email addr of committer (you)
    -if [ -z "$APACHE_EMAIL" ]; then
    -  APACHE_EMAIL=${APACHE_NAME}@apache.org
    -  read -p "  your apache email [$APACHE_EMAIL]: " INPUT
    -  [ -n "$INPUT" ] && APACHE_EMAIL=$INPUT
    +get_contributor_info
     
    -  # write setting to config file, so it is not needed next time
    -  echo "APACHE_EMAIL=$APACHE_EMAIL" >> $CONFIG_FILE
    -fi
    +get_jira_info
     
    -# retrieve the pull request identifier
    -read -p "  pull request: " PR
    -if [ -z "$PR" ]; then
    -  echo "Error: missing pr"
    -  exit 1
    -fi
    +commit
     
    -# ensure that the pull request exists
    -PR_EXISTS=`curl -sI https://api.github.com/repos/apache/${CHOSEN_REPO}/pulls/$PR | grep Status: | sed 's/[^0-9]//g'`
    -if [ "$PR_EXISTS" != "200" ]; then
    -  echo "Error: pull request #$PR does not exist"
    -  exit 1
    -fi
    +review_commit_info
     
    -# working directory
    -WORK=~/tmp/${CHOSEN_REPO}-pr$PR
    -read -p "  local working directory [$WORK]: " INPUT
    -[ -n "$INPUT" ] && WORK=$INPUT
    +run_tests
     
    -# handle tilde expansion
    -WORK="${WORK/#\~/$HOME}"
    +please_review_commit_then
    --- End diff --
    
    s/commit_//


---

[GitHub] metron pull request #1248: METRON-1847 break out functions from prepare-comm...

Posted by JonZeolla <gi...@git.apache.org>.
Github user JonZeolla commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1248#discussion_r228693677
  
    --- Diff: dev-utilities/committer-utils/prepare-commit ---
    @@ -16,242 +16,31 @@
     #  limitations under the License.
     #
     
    -# not likely to change
    -METRON_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron.git"
    -BRO_PLUGIN_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron-bro-plugin-kafka.git"
    -CONFIG_FILE=~/.metron-prepare-commit
    -GITHUB_REMOTE="origin"
    -BASE_BRANCH=master
    +LOCATION_DIR=`dirname $0`
    --- End diff --
    
    `LOCATION_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"`?


---

[GitHub] metron pull request #1248: METRON-1847 break out functions from prepare-comm...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1248#discussion_r228715835
  
    --- Diff: dev-utilities/committer-utils/prepare-commit ---
    @@ -16,242 +16,31 @@
     #  limitations under the License.
     #
     
    -# not likely to change
    -METRON_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron.git"
    -BRO_PLUGIN_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron-bro-plugin-kafka.git"
    -CONFIG_FILE=~/.metron-prepare-commit
    -GITHUB_REMOTE="origin"
    -BASE_BRANCH=master
    +LOCATION_DIR=`dirname $0`
    --- End diff --
    
    nm, you are right



---

[GitHub] metron pull request #1248: METRON-1847 break out functions from prepare-comm...

Posted by ottobackwards <gi...@git.apache.org>.
Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1248#discussion_r228632953
  
    --- Diff: dev-utilities/committer-utils/prepare-commit ---
    @@ -16,242 +16,31 @@
     #  limitations under the License.
     #
     
    -# not likely to change
    -METRON_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron.git"
    -BRO_PLUGIN_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron-bro-plugin-kafka.git"
    -CONFIG_FILE=~/.metron-prepare-commit
    -GITHUB_REMOTE="origin"
    -BASE_BRANCH=master
    +LOCATION_DIR=`dirname $0`
    +#shellcheck source=./metron-committer-common
    --- End diff --
    
    Yes, this a directive for shellcheck
    
    https://github.com/koalaman/shellcheck/wiki/SC1090
    https://github.com/koalaman/shellcheck/wiki/Directive
    



---

[GitHub] metron pull request #1248: METRON-1847 break out functions from prepare-comm...

Posted by nickwallen <gi...@git.apache.org>.
Github user nickwallen commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1248#discussion_r228630285
  
    --- Diff: dev-utilities/committer-utils/prepare-commit ---
    @@ -16,242 +16,31 @@
     #  limitations under the License.
     #
     
    -# not likely to change
    -METRON_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron.git"
    -BRO_PLUGIN_UPSTREAM="https://git-wip-us.apache.org/repos/asf/metron-bro-plugin-kafka.git"
    -CONFIG_FILE=~/.metron-prepare-commit
    -GITHUB_REMOTE="origin"
    -BASE_BRANCH=master
    +LOCATION_DIR=`dirname $0`
    +#shellcheck source=./metron-committer-common
    --- End diff --
    
    Does this need to be commented out?


---

[GitHub] metron pull request #1248: METRON-1847 break out functions from prepare-comm...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/metron/pull/1248


---