HBASE-12249 Addendum - Convert tabs to spaces

This commit is contained in:
Misty Stanley-Jones 2014-10-22 15:17:15 +10:00
parent f6de7efb27
commit dfa98ab93b
1 changed files with 41 additions and 41 deletions

View File

@ -8,14 +8,14 @@ while getopts "ahd:" opt; do
a) addendum='-addendum' a) addendum='-addendum'
;; ;;
d) d)
patch_dir=$OPTARG patch_dir=$OPTARG
;; ;;
*) *)
echo -e "Usage: $0 [-h] [-a] [-d] <directory> \n\ echo -e "Usage: $0 [-h] [-a] [-d] <directory> \n\
Must be run from within the git branch to make the patch against.\n\ Must be run from within the git branch to make the patch against.\n\
-h - display these instructions.\n\ -h - display these instructions.\n\
-a - Add an 'addendum' prefix to the patch name.\n\ -a - Add an 'addendum' prefix to the patch name.\n\
-d - specify a patch directory (defaults to ~/patches/)" -d - specify a patch directory (defaults to ~/patches/)"
exit 0 exit 0
;; ;;
esac esac
@ -24,8 +24,8 @@ done
# Find what branch we are on # Find what branch we are on
branch=$(git branch |grep '*' |awk '{print $2}') branch=$(git branch |grep '*' |awk '{print $2}')
if [ ! "$branch" ]; then if [ ! "$branch" ]; then
echo "Can't determine the git branch. Exiting." >&2 echo "Can't determine the git branch. Exiting." >&2
exit 1 exit 1
fi fi
# Exit if git status is dirty # Exit if git status is dirty
@ -40,14 +40,14 @@ fi
git log -n 1 origin/$branch > /dev/null 2>&1 git log -n 1 origin/$branch > /dev/null 2>&1
status=$? status=$?
if [ "$status" -eq 128 ]; then if [ "$status" -eq 128 ]; then
# Status 128 means there is no remote branch # Status 128 means there is no remote branch
tracking_branch='origin/master' tracking_branch='origin/master'
elif [ "$status" -eq 0 ]; then elif [ "$status" -eq 0 ]; then
# Status 0 means there is a remote branch # Status 0 means there is a remote branch
tracking_branch="origin/$branch" tracking_branch="origin/$branch"
else else
echo "Unknown error: $?" >&2 echo "Unknown error: $?" >&2
exit 1 exit 1
fi fi
# Deal with invalid or missing $patch_dir # Deal with invalid or missing $patch_dir
@ -65,31 +65,31 @@ fi
# Check to see if any patch exists that includes the branch name # Check to see if any patch exists that includes the branch name
status=$(ls $patch_dir/*$branch* 2>/dev/null|grep -v addendum|wc -l|awk {'print $1'}) status=$(ls $patch_dir/*$branch* 2>/dev/null|grep -v addendum|wc -l|awk {'print $1'})
if [ "$status" -eq 0 ]; then if [ "$status" -eq 0 ]; then
# This is the first patch we are making for this release # This is the first patch we are making for this release
prefix='' prefix=''
elif [ "$status" -ge 1 ]; then elif [ "$status" -ge 1 ]; then
# At least one patch already exists -- add a version prefix # At least one patch already exists -- add a version prefix
for i in {1..99}; do for i in {1..99}; do
# Check to see the maximum version of patch that exists # Check to see the maximum version of patch that exists
if [ ! -f "$patch_dir/$branch-v$i.patch" ]; then if [ ! -f "$patch_dir/$branch-v$i.patch" ]; then
version=$i version=$i
if [ -n "$addendum" ]; then if [ -n "$addendum" ]; then
# Don't increment the patch # if it is an addendum # Don't increment the patch # if it is an addendum
echo "Creating an addendum" echo "Creating an addendum"
if [ "$version" -eq 1 ]; then if [ "$version" -eq 1 ]; then
# We are creating an addendum to the first version of the patch # We are creating an addendum to the first version of the patch
prefix='' prefix=''
else else
# We are making an addendum to a different version of the patch # We are making an addendum to a different version of the patch
let version=$version-1 let version=$version-1
prefix="-v$version" prefix="-v$version"
fi fi
else else
prefix="-v$version" prefix="-v$version"
fi fi
break break
fi fi
done done
fi fi
patch_name="$branch$prefix$addendum.patch" patch_name="$branch$prefix$addendum.patch"
@ -98,19 +98,19 @@ patch_name="$branch$prefix$addendum.patch"
git diff --quiet $tracking_branch git diff --quiet $tracking_branch
status=$? status=$?
if [ "$status" -eq 0 ]; then if [ "$status" -eq 0 ]; then
echo "There is no difference between $branch and $tracking_branch." echo "There is no difference between $branch and $tracking_branch."
echo "No patch created." echo "No patch created."
exit 0 exit 0
fi fi
# Check whether we need to squash or not # Check whether we need to squash or not
local_commits=$(git log $tracking_branch..$branch|grep 'Author:'|wc -l|awk {'print $1'}) local_commits=$(git log $tracking_branch..$branch|grep 'Author:'|wc -l|awk {'print $1'})
if [ "$local_commits" -gt 1 ]; then if [ "$local_commits" -gt 1 ]; then
read -p "$local_commits commits exist only in your local branch. Interactive rebase?" yn read -p "$local_commits commits exist only in your local branch. Interactive rebase?" yn
case $yn in case $yn in
[Yy]* ) [Yy]* )
git rebase -i $tracking_branch git rebase -i $tracking_branch
;; ;;
[Nn]* ) [Nn]* )
echo "Creating $patch_dir/$patch_name using git diff." echo "Creating $patch_dir/$patch_name using git diff."
git diff $tracking_branch > $patch_dir/$patch_name git diff $tracking_branch > $patch_dir/$patch_name