# ignite-sprint-5: improve git-format-patch.sh (add check on current branch != default branch)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4701d6d2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4701d6d2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4701d6d2 Branch: refs/heads/ignite-389 Commit: 4701d6d2265ec3c36de76b8f3026be8e6c24932a Parents: 8719b73 Author: ashutak <ashu...@gridgain.com> Authored: Tue Jun 2 19:53:05 2015 +0300 Committer: ashutak <ashu...@gridgain.com> Committed: Tue Jun 2 19:53:05 2015 +0300 ---------------------------------------------------------------------- scripts/git-apply-patch.sh | 8 ++++---- scripts/git-format-patch.sh | 6 +++--- scripts/git-patch-functions.sh | 36 ++++++++++++++++++++++-------------- 3 files changed, 29 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4701d6d2/scripts/git-apply-patch.sh ---------------------------------------------------------------------- diff --git a/scripts/git-apply-patch.sh b/scripts/git-apply-patch.sh index c5f686f..757cd26 100755 --- a/scripts/git-apply-patch.sh +++ b/scripts/git-apply-patch.sh @@ -56,18 +56,18 @@ do IGNITE_HOME="$2" shift ;; - + -idb|--ignitedefbranch) IGNITE_DEFAULT_BRANCH="$2" shift ;; - + -ph|--patchhome) PATCHES_HOME="$2" shift ;; *) - + echo "Unknown parameter: ${key}" ;; esac @@ -75,7 +75,7 @@ do done echo "IGNITE_HOME : ${IGNITE_HOME}" -echo "Master branch : ${IGNITE_DEFAULT_BRANCH}" +echo "Default branch : ${IGNITE_DEFAULT_BRANCH}" echo "Ignite task : ${IGNITE_TASK}" echo echo "PATCHES_HOME : ${PATCHES_HOME}" http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4701d6d2/scripts/git-format-patch.sh ---------------------------------------------------------------------- diff --git a/scripts/git-format-patch.sh b/scripts/git-format-patch.sh index 5aa2075..b11c73d 100755 --- a/scripts/git-format-patch.sh +++ b/scripts/git-format-patch.sh @@ -20,9 +20,9 @@ # Git patch-file maker. # echo 'Usage: scripts/git-format-patch.sh [-ih|--ignitehome <path>] [-idb|--ignitedefbranch <branch-name>] [-ph|--patchhome <path>]' -echo 'It is a script to create patch between current and default branches. The script is safe and do not broke or lose your changes.' +echo 'It is a script to create patch between Current branch (branch with changes) and Default branche. The script is safe and do not broke or lose your changes.' echo "It should be called from IGNITE_HOME directory." -echo "Patch will be created at PATCHES_HOME (= IGNITE_HOME, by default) between Master branch (IGNITE_DEFAULT_BRANCH) and Current branch." +echo "Patch will be created at PATCHES_HOME (= IGNITE_HOME, by default) between Default 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 'Examples:' echo '- Basic (with all defaults and properties from git-patch-prop.sh): ./scripts/git-format-patch.sh' @@ -76,7 +76,7 @@ done IGNITE_CURRENT_BRANCH=$( determineCurrentBranch ${IGNITE_HOME} ) echo "IGNITE_HOME : ${IGNITE_HOME}" -echo "Master branch : ${IGNITE_DEFAULT_BRANCH}" +echo "Default branch : ${IGNITE_DEFAULT_BRANCH}" echo "Current branch : ${IGNITE_CURRENT_BRANCH}" echo echo "PATCHES_HOME : ${PATCHES_HOME}" http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4701d6d2/scripts/git-patch-functions.sh ---------------------------------------------------------------------- diff --git a/scripts/git-patch-functions.sh b/scripts/git-patch-functions.sh index 796bccd..3cc1bb0 100644 --- a/scripts/git-patch-functions.sh +++ b/scripts/git-patch-functions.sh @@ -39,6 +39,14 @@ formatPatch () { PATCHED_BRANCH=$3 PATCH_SUFFIX=$4 + if [ ${IGNITE_CURRENT_BRANCH} = ${IGNITE_DEFAULT_BRANCH} ] + then + echo $0", ERROR:" + echo "You are on Default branch. Please, checkout branch with changes." + + exit 1 + fi + cd ${GIT_HOME} git checkout ${DEFAULT_BRANCH} @@ -54,15 +62,15 @@ formatPatch () { echo "Patch file created." git checkout ${PATCHED_BRANCH} - + git branch -D tmppatch # Delete tmp branch. - - echo + + echo echo "Patch created: ${PATCH_FILE}" } # -# Determines current branch. +# Determines Current branch. # # Params: # - Git home. @@ -70,11 +78,11 @@ formatPatch () { # determineCurrentBranch () { GIT_HOME=$1 - + cd ${GIT_HOME} - + CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` - + echo "$CURRENT_BRANCH" } @@ -131,22 +139,22 @@ applyPatch () { 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 am ${PATCH_FILE} } # -# Checks that given default branch and current branch are equal. +# Checks that given Default branch and Current branch are equal. # Exit with code 1 in error case. # # Params: @@ -160,12 +168,12 @@ currentAndDefaultBranchesShouldBeEqual () { cd ${GIT_HOME} CURRENT_BRANCH=$( determineCurrentBranch ${GIT_HOME} ) - + if [ "$CURRENT_BRANCH" != "$DEFAULT_BRANCH" ] - then + 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 }