You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/03/04 11:10:26 UTC
incubator-ignite git commit: # gg-9869: extract git-patch-functions.sh
Repository: incubator-ignite
Updated Branches:
refs/heads/gg-9869 2fe52f6ed -> 380a53da5
# gg-9869: extract git-patch-functions.sh
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/380a53da
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/380a53da
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/380a53da
Branch: refs/heads/gg-9869
Commit: 380a53da59cfd204007bd3616d5f45c40542ad8c
Parents: 2fe52f6
Author: Artem Shutak <as...@gridgain.com>
Authored: Wed Mar 4 13:10:50 2015 +0300
Committer: Artem Shutak <as...@gridgain.com>
Committed: Wed Mar 4 13:10:50 2015 +0300
----------------------------------------------------------------------
scripts/git-format-patch.sh | 129 +++++++-----------------------------
scripts/git-patch-functions.sh | 106 +++++++++++++++++++++++++++++
2 files changed, 130 insertions(+), 105 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/380a53da/scripts/git-format-patch.sh
----------------------------------------------------------------------
diff --git a/scripts/git-format-patch.sh b/scripts/git-format-patch.sh
index bb84a2b..7df08dc 100644
--- a/scripts/git-format-patch.sh
+++ b/scripts/git-format-patch.sh
@@ -20,121 +20,40 @@
# Git patch-file maker.
#
-echo 'Usage: git-format-patch.sh <BRANCH_WITH_PATCH>'
-echo
-
-PATCHED_BRANCH=$1
-MODE=$2
-
-if [ "${GG_HOME}" = "" ];
- then GG_HOME=$PWD
+#
+# Imports and init
+#
+if [ -z ${IGNITE_HOME} ] # Script can be called from not IGNITE_HOME if IGNITE_HOME was set.
+ then IGNITE_HOME=$PWD
fi
-. ${GG_HOME}/scripts/git-patch-prop.sh # Import properties.
-. ${GG_HOME}/scripts/git-patch-prop-local.sh # Import user properties (it will rewrite global properties).
+. ${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
-# Define functions.
-formatPatch () {
- GIT_HOME=$1
- DEFAULT_BRANCH=$2
- PATCHED_BRANCH=$3
- PATCH_SUFFIX=$4
-
- echo
- echo '>>> FORMAT PATCH FOR BRANCHES '${DEFAULT_BRANCH}' AND '${PATCHED_BRANCH}' AT '${GIT_HOME}
- echo
-
- cd ${GIT_HOME}
-
-# echo '>>>>>> Checkout '${DEFAULT_BRANCH}
-# git checkout ${DEFAULT_BRANCH}
+echo 'Usage: scripts/git-format-patch.sh.'
+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
+echo "PATCHES_HOME: ${PATCHES_HOME}"
+echo "Master branch: ${IGNITE_DEFAULT_BRANCH}"
+echo "Current branch: ${PATCHED_BRANCH}"
-# echo '>>>>>> Create tmpsquash.'
-# git checkout -b tmpsquash
#
-# echo '>>>>>> Merge '${PATCHED_BRANCH}' at tmpsquash'
-# git merge --squash ${PATCHED_BRANCH}
-# git commit -a -m "My squashed commits"
-
- git checkout ${PATCHED_BRANCH}
-
- echo '>>>>>> Format patch.'
- git format-patch ${DEFAULT_BRANCH} --stdout > ${PATCHES_HOME}'/'${DEFAULT_BRANCH}_${PATCHED_BRANCH}${PATCH_SUFFIX}
-
-# echo '>>>>>> Clean-up.'
- git checkout ${DEFAULT_BRANCH}
-# git branch -D tmpsquash # Delete tmp branch.
-}
-
-updateBranches () {
- GIT_HOME=$1
- DEFAULT_BRANCH=$2
- PATCHED_BRANCH=$3
-
- echo
- echo '>>> UPDATING BRANCHES '${DEFAULT_BRANCH}' AND '${PATCHED_BRANCH}' AT '${GIT_HOME}
- echo
-
- cd ${GIT_HOME}
-
- git checkout ${DEFAULT_BRANCH}
- git pull
-
- git checkout ${PATCHED_BRANCH}
- echo
- echo '>>>>>> START MERGING'
- echo
- git merge --no-edit ${DEFAULT_BRANCH} # Merge with default message.
-}
-
-# Return value of checkBranchExists function.
-BRANCH_EXISTS=''
-
-checkBranchExists () {
- GIT_HOME=$1
- BRANCH=$2
-
- cd ${GIT_HOME}
-
- BRANCH_EXISTS=`git show-ref refs/heads/"${BRANCH}"`
-}
-
-
-exitIfBranchDoesNotExist () {
- checkBranchExists $1 $2
-
- if [ -z "$BRANCH_EXISTS" ] # If not.
- then
- echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
- echo ">>>>>>>>>>>>>>>>>>>>>>>>>> ERROR >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
- echo ">>> Expected branch ${BRANCH} does not exist at ${GIT_HOME}"
- echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
-
- exit
- fi
-}
-
# Main script logic.
+#
-# Ignite project.
-checkBranchExists ${IGNITE_HOME} ${PATCHED_BRANCH}
-
-if [ -n "$BRANCH_EXISTS" ]
-then
- exitIfBranchDoesNotExist ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH}
-
- updateBranches ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH} ${PATCHED_BRANCH}
- formatPatch ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH} ${PATCHED_BRANCH} _ignite.patch
-fi
+exitIfThereAreUncommittedChanges
-# GridGain project.
-checkBranchExists ${GG_HOME} ${PATCHED_BRANCH}
+checkBranchExists ${IGNITE_HOME} ${CURRENT_BRANCH}
-if [ -n "$BRANCH_EXISTS" ]
+if [ -n ${BRANCH_EXISTS} ]
then
- exitIfBranchDoesNotExist ${GG_HOME} ${GG_DEFAULT_BRANCH}
+ exitIfBranchDoesNotExist ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH}
- updateBranches ${GG_HOME} ${GG_DEFAULT_BRANCH} ${PATCHED_BRANCH}
- formatPatch ${GG_HOME} ${GG_DEFAULT_BRANCH} ${PATCHED_BRANCH} _gg.patch
+ updateBranches ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH} ${CURRENT_BRANCH}
+ formatPatch ${IGNITE_HOME} ${IGNITE_DEFAULT_BRANCH} ${CURRENT_BRANCH} _ignite.patch
fi
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/380a53da/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..971db16
--- /dev/null
+++ b/scripts/git-patch-functions.sh
@@ -0,0 +1,106 @@
+#!/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
+
+ echo
+ echo '>>> FORMAT PATCH FOR BRANCHES '${DEFAULT_BRANCH}' AND '${PATCHED_BRANCH}' AT '${GIT_HOME}
+ echo
+
+ cd ${GIT_HOME}
+
+# echo '>>>>>> Checkout '${DEFAULT_BRANCH}
+# git checkout ${DEFAULT_BRANCH}
+
+# echo '>>>>>> Create tmpsquash.'
+# git checkout -b tmpsquash
+#
+# echo '>>>>>> Merge '${PATCHED_BRANCH}' at tmpsquash'
+# git merge --squash ${PATCHED_BRANCH}
+# git commit -a -m "My squashed commits"
+
+ git checkout ${PATCHED_BRANCH}
+
+ echo '>>>>>> Format patch.'
+ git format-patch ${DEFAULT_BRANCH} --stdout > ${PATCHES_HOME}'/'${DEFAULT_BRANCH}_${PATCHED_BRANCH}${PATCH_SUFFIX}
+
+# echo '>>>>>> Clean-up.'
+ git checkout ${DEFAULT_BRANCH}
+# git branch -D tmpsquash # Delete tmp branch.
+}
+
+updateBranches () {
+ GIT_HOME=$1
+ DEFAULT_BRANCH=$2
+ PATCHED_BRANCH=$3
+
+ echo
+ echo '>>> UPDATING BRANCHES '${DEFAULT_BRANCH}' AND '${PATCHED_BRANCH}' AT '${GIT_HOME}
+ echo
+
+ cd ${GIT_HOME}
+
+ git checkout ${DEFAULT_BRANCH}
+ git pull
+
+ git checkout ${PATCHED_BRANCH}
+ echo
+ echo '>>>>>> START MERGING'
+ echo
+ git merge --no-edit ${DEFAULT_BRANCH} # Merge with default message.
+}
+
+#
+# Return value of checkBranchExists function.
+#
+BRANCH_EXISTS=''
+
+checkBranchExists () {
+ GIT_HOME=$1
+ BRANCH=$2
+
+ cd ${GIT_HOME}
+
+ BRANCH_EXISTS=`git show-ref refs/heads/"${BRANCH}"`
+}
+
+
+exitIfBranchDoesNotExist () {
+ checkBranchExists $1 $2
+
+ if [ -z "$BRANCH_EXISTS" ] # If not.
+ then
+ echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+ echo ">>>>>>>>>>>>>>>>>>>>>>>>>> ERROR >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+ echo ">>> Expected branch ${BRANCH} does not exist at ${GIT_HOME}"
+ echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
+
+ exit
+ fi
+}