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 A458017535 for ; Mon, 6 Apr 2015 10:45:39 +0000 (UTC) Received: (qmail 15591 invoked by uid 500); 6 Apr 2015 10:45:34 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 15523 invoked by uid 500); 6 Apr 2015 10:45:34 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 15421 invoked by uid 99); 6 Apr 2015 10:45:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 10:45:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 06 Apr 2015 10:45:31 +0000 Received: (qmail 13846 invoked by uid 99); 6 Apr 2015 10:45:11 -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; Mon, 06 Apr 2015 10:45:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1C003E1085; Mon, 6 Apr 2015 10:45:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sevdokimov@apache.org To: commits@ignite.incubator.apache.org Date: Mon, 06 Apr 2015 10:45:25 -0000 Message-Id: <98f27081bf4a49b78342bb714e27eed4@git.apache.org> In-Reply-To: <270d8a9f3e8a4dabb093847fa8022f62@git.apache.org> References: <270d8a9f3e8a4dabb093847fa8022f62@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [16/43] incubator-ignite git commit: # patch-scripts: Implemented (format and apply ). X-Virus-Checked: Checked by ClamAV on apache.org # patch-scripts: Implemented (format and apply ). Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/82a93c5c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/82a93c5c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/82a93c5c Branch: refs/heads/gg-10036 Commit: 82a93c5cdb0d8cad85af5e8de57e9fde0c1a1a97 Parents: 3af6914 Author: Artem Shutak Authored: Fri Apr 3 16:30:44 2015 +0300 Committer: Artem Shutak Committed: Fri Apr 3 16:30:44 2015 +0300 ---------------------------------------------------------------------- .gitignore | 2 +- scripts/git-apply-patch.sh | 88 ++++++++++++++++++++++++ scripts/git-format-patch.sh | 84 +++++++++++++++++++++++ scripts/git-patch-functions.sh | 132 ++++++++++++++++++++++++++++++++++++ scripts/git-patch-prop.sh | 28 ++++++++ 5 files changed, 333 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/82a93c5c/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index cd1e894..296e130 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,6 @@ xcuserdata/ atlassian-ide-plugin.xml *.iml target -target/* /libs/ pom-installed.xml +git-patch-prop-local.sh \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/82a93c5c/scripts/git-apply-patch.sh ---------------------------------------------------------------------- diff --git a/scripts/git-apply-patch.sh b/scripts/git-apply-patch.sh new file mode 100644 index 0000000..448421b --- /dev/null +++ b/scripts/git-apply-patch.sh @@ -0,0 +1,88 @@ +#!/bin/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. +# + +# +# Git patch-file applyer. +# +echo 'Usage: scripts/git-apply-patch.sh [-ih|--ignitehome ] [-idb|--ignitedefbranch ] [-ph|--patchhome ]' +echo "It should be called from IGNITE_HOME directory." +echo "Patch will be applied to DEFAULT_BRANCH from PATCHES_HOME." +echo "Note: you can use ${IGNITE_HOME}/scripts/git-patch-prop-local.sh to set your own local properties (to rewrite settings at git-patch-prop-local.sh). " +echo + +# +# Ignite task. +# +IGNITE_TASK=$1 + +# +# Read command line params. +# +while [[ $# > 1 ]] +do + key="$1" + + case $key in + -ih|--ignitehome) + IGNITE_HOME="$2" + shift + ;; + -idb|--ignitedefbranch) + IGNITE_DEFAULT_BRANCH="$2" + shift + ;; + -ph|--patchhome) + PATCHES_HOME="$2" + shift + ;; + *) + # unknown option + ;; + esac + shift +done + +if [ -z ${IGNITE_HOME} ] # Script can be called from not IGNITE_HOME if IGNITE_HOME was set. + then IGNITE_HOME=$PWD +fi + +. ${IGNITE_HOME}/scripts/git-patch-prop.sh # Import properties. +. ${IGNITE_HOME}/scripts/git-patch-functions.sh # Import patch functions. + +if [ -f ${IGNITE_HOME}/scripts/git-patch-prop-local.sh ] # Whether a local user properties file exists. + then . ${IGNITE_HOME}/scripts/git-patch-prop-local.sh # Import user properties (it will rewrite global properties). +fi + +echo "IGNITE_HOME : ${IGNITE_HOME}" +echo "Master branch : ${IGNITE_DEFAULT_BRANCH}" +echo "Ignite task : ${IGNITE_TASK}" +echo +echo "PATCHES_HOME : ${PATCHES_HOME}" +echo + +# +# Main script logic. +# + +currentAndDefaultBranchesShouldBeEqual ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH} + +requireCleanWorkTree ${IGNITE_HOME} + +IGNITE_PATCH_FILE=${PATCHES_HOME}/${IGNITE_DEFAULT_BRANCH}_${IGNITE_TASK}_ignite.patch + +applyPatch ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH} ${IGNITE_PATCH_FILE} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/82a93c5c/scripts/git-format-patch.sh ---------------------------------------------------------------------- diff --git a/scripts/git-format-patch.sh b/scripts/git-format-patch.sh new file mode 100644 index 0000000..575a7bb --- /dev/null +++ b/scripts/git-format-patch.sh @@ -0,0 +1,84 @@ +#!/bin/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. +# + +# +# Git patch-file maker. +# +echo 'Usage: scripts/git-format-patch.sh [-ih|--ignitehome ] [-idb|--ignitedefbranch ] [-ph|--patchhome ]' +echo "It should be called from IGNITE_HOME directory." +echo "Patch will be created at PATCHES_HOME between Master branch (IGNITE_DEFAULT_BRANCH) and Current branch." +echo "Note: you can use ${IGNITE_HOME}/scripts/git-patch-prop-local.sh to set your own local properties (to rewrite settings at git-patch-prop-local.sh). " +echo + +# +# Read command line params. +# +while [[ $# > 1 ]] +do + key="$1" + + case $key in + -ih|--ignitehome) + IGNITE_HOME="$2" + shift + ;; + -idb|--ignitedefbranch) + IGNITE_DEFAULT_BRANCH="$2" + shift + ;; + -ph|--patchhome) + PATCHES_HOME="$2" + shift + ;; + *) + # unknown option + ;; + esac + shift +done + +# +# Init home and import properties and functions. +# +if [ -z ${IGNITE_HOME} ] # Script can be called from not IGNITE_HOME if IGNITE_HOME was set. + then IGNITE_HOME=$PWD +fi + +. ${IGNITE_HOME}/scripts/git-patch-prop.sh # Import properties. +. ${IGNITE_HOME}/scripts/git-patch-functions.sh # Import patch functions. + +if [ -f ${IGNITE_HOME}/scripts/git-patch-prop-local.sh ] # Whether a local user properties file exists. + then . ${IGNITE_HOME}/scripts/git-patch-prop-local.sh # Import user properties (it will rewrite global properties). +fi + +IGNITE_CURRENT_BRANCH=$( determineCurrentBranch ${IGNITE_HOME} ) + +echo "IGNITE_HOME : ${IGNITE_HOME}" +echo "Master branch : ${IGNITE_DEFAULT_BRANCH}" +echo "Current branch : ${IGNITE_CURRENT_BRANCH}" +echo +echo "PATCHES_HOME : ${PATCHES_HOME}" +echo + +# +# Main script logic. +# + +requireCleanWorkTree ${IGNITE_HOME} + +formatPatch ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH} ${IGNITE_CURRENT_BRANCH} _ignite.patch \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/82a93c5c/scripts/git-patch-functions.sh ---------------------------------------------------------------------- diff --git a/scripts/git-patch-functions.sh b/scripts/git-patch-functions.sh new file mode 100644 index 0000000..ab9bec3 --- /dev/null +++ b/scripts/git-patch-functions.sh @@ -0,0 +1,132 @@ +#!/bin/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. +# + +# +# Git patch functions. +# + +# +# Define functions. +# +formatPatch () { + GIT_HOME=$1 + DEFAULT_BRANCH=$2 + PATCHED_BRANCH=$3 + PATCH_SUFFIX=$4 + + cd ${GIT_HOME} + + git checkout ${DEFAULT_BRANCH} + git checkout -b tmppatch + + git merge --no-edit ${PATCHED_BRANCH} +# Or we can 'squashe' merge to make only one commit. +# git merge --squash ${PATCHED_BRANCH} +# git commit -a -m "# PATCHED_BRANCH" + + PATCH_FILE=${PATCHES_HOME}'/'${DEFAULT_BRANCH}_${PATCHED_BRANCH}${PATCH_SUFFIX} + + git format-patch ${DEFAULT_BRANCH} --stdout > ${PATCH_FILE} + echo "Patch file created." + + git checkout ${PATCHED_BRANCH} + + git branch -D tmppatch # Delete tmp branch. + + echo + echo "Patch created: ${PATCH_FILE}" +} + +determineCurrentBranch () { + GIT_HOME=$1 + + cd ${GIT_HOME} + + CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` + + echo "$CURRENT_BRANCH" +} + +requireCleanWorkTree () { + cd $1 # At git home. + + # Update the index + git update-index -q --ignore-submodules --refresh + err=0 + + # Disallow unstaged changes in the working tree + if ! git diff-files --quiet --ignore-submodules -- + then + echo $0", ERROR:" + echo >&2 "You have unstaged changes." + git diff-files --name-status -r --ignore-submodules -- >&2 + err=1 + fi + + # Disallow uncommitted changes in the index + if ! git diff-index --cached --quiet HEAD --ignore-submodules -- + then + echo $0", ERROR:" + echo >&2 "Your index contains uncommitted changes." + git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 + err=1 + fi + + if [ $err = 1 ] + then + echo >&2 "Please commit or stash them." + exit 1 + fi +} + +applyPatch () { + GIT_HOME=$1 + DEFAULT_BRANCH=$2 + PATCH_FILE=$3 + + cd ${GIT_HOME} + + if [ ! -f ${PATCH_FILE} ] + then + echo $0", ERROR:" + echo "Expected patch file not found: $PATCH_FILE." + + exit 1 + fi + + echo "Patch $PATCH_FILE will be applied to $DEFAULT_BRANCH branch." +# git apply ${PATCH_FILE} + git am ${PATCH_FILE} +} + +currentAndDefaultBranchesShouldBeEqual () { + GIT_HOME=$1 + DEFAULT_BRANCH=$2 + + cd ${GIT_HOME} + + CURRENT_BRANCH=$( determineCurrentBranch ${GIT_HOME} ) + + if [ "$CURRENT_BRANCH" != "$DEFAULT_BRANCH" ] + then + echo $0", ERROR:" + echo "You are not on an expected branch. Your current branch at $GIT_HOME is $CURRENT_BRANCH, should be $DEFAULT_BRANCH." + + exit 1 + fi +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/82a93c5c/scripts/git-patch-prop.sh ---------------------------------------------------------------------- diff --git a/scripts/git-patch-prop.sh b/scripts/git-patch-prop.sh new file mode 100644 index 0000000..7eb3639 --- /dev/null +++ b/scripts/git-patch-prop.sh @@ -0,0 +1,28 @@ +#!/bin/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. +# + +# +# Git patch-file maker/applyer properties. +# +if [ "${IGNITE_DEFAULT_BRANCH}" = "" ] + then IGNITE_DEFAULT_BRANCH='sprint-2' +fi + +if [ "${PATCHES_HOME}" = "" ] + then PATCHES_HOME=${GG_HOME} +fi \ No newline at end of file