Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6C552100FA for ; Tue, 8 Sep 2015 16:34:40 +0000 (UTC) Received: (qmail 18178 invoked by uid 500); 8 Sep 2015 16:34:40 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 18143 invoked by uid 500); 8 Sep 2015 16:34:40 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 18128 invoked by uid 99); 8 Sep 2015 16:34:40 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Sep 2015 16:34:40 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2888BDFF7E; Tue, 8 Sep 2015 16:34:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ntikhonov@apache.org To: commits@ignite.apache.org Date: Tue, 08 Sep 2015 16:34:40 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] ignite git commit: ignite-1383: Fixed. Repository: ignite Updated Branches: refs/heads/ignite-1.4 b8db248e6 -> e4e39af68 ignite-1383: Fixed. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/108dd8f9 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/108dd8f9 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/108dd8f9 Branch: refs/heads/ignite-1.4 Commit: 108dd8f9721b80a5355bd0b472037276ad7d4c5f Parents: db827cf Author: ashutak Authored: Tue Sep 8 17:30:15 2015 +0300 Committer: ashutak Committed: Tue Sep 8 17:30:15 2015 +0300 ---------------------------------------------------------------------- scripts/apply-pull-request.sh | 141 ++++++++++++++++++++++++++++--------- 1 file changed, 109 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/108dd8f9/scripts/apply-pull-request.sh ---------------------------------------------------------------------- diff --git a/scripts/apply-pull-request.sh b/scripts/apply-pull-request.sh index d852d78..dd2b78c 100755 --- a/scripts/apply-pull-request.sh +++ b/scripts/apply-pull-request.sh @@ -19,66 +19,139 @@ # # Pull request applier. # -echo 'Usage: scripts/apply-pull-request.sh ' -echo 'The script takes pull-request by given id and merges (with squash) all changes too master branch.' -echo "Argument 'pull-request-id' is mandatory." -echo -IGNITE_HOME="$(dirname "$(cd "$(dirname "$0")"; "pwd")")"; +# +# Start of Functions. +# + +# +# Prints usage. +# +usage () { + echo 'Usage: scripts/apply-pull-request.sh [-tb|--targetbranch ]' + echo 'The script takes pull-request by given id and merges (with squash) all changes to target branch (master by default).' + echo "Argument 'pull-request-id' is mandatory." + echo "Target branch can be overwritten by using [-tb|--targetbranch ] argument paramethers." +} + +# +# End of Functions. +# + +if [ "${GIT_HOME}" = "" ]; then + GIT_HOME="$(dirname "$(cd "$(dirname "$0")"; "pwd")")"; +fi -. ${IGNITE_HOME}/scripts/git-patch-functions.sh # Import patch functions. +cd ${GIT_HOME} -# Constants. -APACHE_GIT="https://git-wip-us.apache.org/repos/asf/ignite" -GITHUB_MIRROR="https://github.com/apache/ignite.git" +if [ "${SCRIPTS_HOME}" = "" ]; then + SCRIPTS_HOME="${GIT_HOME}/scripts/" +fi + +. ${SCRIPTS_HOME}/git-patch-functions.sh # Import patch functions. -# Get paramethers. PR_ID=$1 -# Initial checks. +# +# Start reading of command line params. +# if [ "${PR_ID}" = "" ]; then echo $0", ERROR:" echo >&2 "You have to specify 'pull-request-id'." + echo + usage exit 1 fi -requireCleanWorkTree ${IGNITE_HOME} +if [ "${PR_ID}" = "-h" ]; then + usage + exit 0 +fi + +if [ "${PR_ID}" = "--help" ]; then + usage + exit 0 +fi + + +while [[ $# > 2 ]] +do + key="$2" + + case $key in + -tb|--targetbranch) + TARGET_BRANCH="$3" + shift + ;; + + *) + echo "Unknown parameter: ${key}" + echo + usage + ;; + esac + shift +done +# +# Enf reading of command line params. +# + + +# Script variables. +if [ "${APACHE_GIT}" = "" ]; then + APACHE_GIT="https://git-wip-us.apache.org/repos/asf/ignite" +fi + +if [ "${GITHUB_MIRROR}" = "" ]; then + GITHUB_MIRROR="https://github.com/apache/ignite.git" +fi + +if [ "${TARGET_BRANCH}" = "" ]; then + TARGET_BRANCH="master" +fi + +requireCleanWorkTree ${GIT_HOME} CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` -if [ "$CURRENT_BRANCH" != "master" ]; then +if [ "$CURRENT_BRANCH" != "${TARGET_BRANCH}" ]; then echo $0", ERROR:" - echo "You have to be on master branch." + echo "You have to be on ${TARGET_BRANCH} branch." exit 1 fi -# Check that master is up-to-date. -APACHE_GIT_MASTER_BRANCH="apache-git-master-tmp" +# Check that target branch is up-to-date. +APACHE_GIT_TARGET_BRANCH="apache-git-target-br-tmp" -git fetch ${APACHE_GIT} master:${APACHE_GIT_MASTER_BRANCH} &> /dev/null +git fetch ${APACHE_GIT} ${TARGET_BRANCH}:${APACHE_GIT_TARGET_BRANCH} &> /dev/null +if test $? != 0; then + echo $0", ERROR:" + echo >&2 "Couldn't fetch '${TARGET_BRANCH}' branch from ${APACHE_GIT}." + exit 1 +fi -LOCAL_MASTER_HASH=$(git rev-parse @) -REMOTE_MASTER_HASH=$(git rev-parse ${APACHE_GIT_MASTER_BRANCH}) -BASE_HASH=$(git merge-base @ ${APACHE_GIT_MASTER_BRANCH}) +LOCAL_TARGET_BR_HASH=$(git rev-parse @) +REMOTE_TARGET_BR_HASH=$(git rev-parse ${APACHE_GIT_TARGET_BRANCH}) +BASE_HASH=$(git merge-base @ ${APACHE_GIT_TARGET_BRANCH}) -git branch -D ${APACHE_GIT_MASTER_BRANCH} &> /dev/null +git branch -D ${APACHE_GIT_TARGET_BRANCH} &> /dev/null -if [ $LOCAL_MASTER_HASH != $REMOTE_MASTER_HASH ]; then +if [ $LOCAL_TARGET_BR_HASH != $REMOTE_TARGET_BR_HASH ]; then echo $0", ERROR:" - if [ $LOCAL_MASTER_HASH = $BASE_HASH ]; then - echo "Your local master branch is not up-to-date. You need to pull." - elif [ $REMOTE_MASTER_HASH = $BASE_HASH ]; then - echo "Your local master branch is ahead of master branch at Apache git. You need to push." + if [ $LOCAL_TARGET_BR_HASH = $BASE_HASH ]; then + echo "Your local ${TARGET_BRANCH} branch is not up-to-date. You need to pull." + elif [ $REMOTE_TARGET_BR_HASH = $BASE_HASH ]; then + echo "Your local ${TARGET_BRANCH} branch is ahead of ${TARGET_BRANCH} branch at Apache git. You need to push." else - echo "Your local master and Apache git master branches diverged. You need to pull, merge and pull." + echo "Your local ${TARGET_BRANCH} and Apache git ${TARGET_BRANCH} branches diverged. You need to pull, merge and pull." fi exit 1 fi -echo "Local master is Up-to-date." +echo "Local ${TARGET_BRANCH} is Up-to-date." echo # Checkout pull-request branch. @@ -105,8 +178,8 @@ ORIG_COMMENT="$(git log -1 --pretty=%B)" echo "Author of pull-request: '$AUTHOR'." echo -# Update local master. -git checkout master &> /dev/null +# Update local target branch. +git checkout ${TARGET_BRANCH} &> /dev/null # Take changes. git merge --squash ${PR_BRANCH_NAME} &> /dev/null @@ -114,7 +187,7 @@ if test $? != 0; then git reset --hard &> /dev/null echo $0", ERROR:" - echo >&2 "Could not merge the pull-request to master without conflicts. All local changes have been discarded. You're on master branch." + echo >&2 "Could not merge the pull-request to ${TARGET_BRANCH} without conflicts. All local changes have been discarded. You're on ${TARGET_BRANCH} branch." exit 1 fi @@ -130,10 +203,14 @@ fi COMMENT="${COMMENT} - Fixes #${PR_ID}." +if [ "${EXCLUDE_SPECIAL_FILE}" = "true" ]; then + git checkout HEAD ignite-pull-request-id +fi + git commit --author "${AUTHOR}" -a -s -m "${COMMENT}" &> /dev/null echo "Squash commit for pull request with id='${PR_ID}' has been added. The commit has been added with comment '${COMMENT}'." -echo "Now you can review changes of the last commit at master and push it to Ignite Apche git after." +echo "Now you can review changes of the last commit at ${TARGET_BRANCH} and push it into ${APACHE_GIT} git after." echo "If you want to decline changes, you can remove the last commit from your repo by 'git reset --hard HEAD^'." echo