HBASE-15725 make_patch.sh should add the branch name when -b is passed.

This commit is contained in:
Elliott Clark 2016-05-12 11:15:57 -07:00
parent b353e388bb
commit 0e281e1929
1 changed files with 12 additions and 7 deletions

View File

@ -24,7 +24,7 @@ while getopts "ahd:b:" opt; do
case "$opt" in
a) addendum='-addendum'
;;
d)
d)
patch_dir=$OPTARG
;;
b)
@ -52,7 +52,7 @@ fi
# Exit if git status is dirty
git_dirty=$(git diff --shortstat 2> /dev/null | wc -l|awk {'print $1'})
echo "git_dirty is $git_dirty"
if [ "$git_dirty" -ne 0 ]; then
if [ "$git_dirty" -ne 0 ]; then
echo "Git status is dirty. Commit locally first.">&2
exit 1
fi
@ -117,8 +117,15 @@ elif [ "$status" -ge 1 ]; then
fi
done
fi
# If this is against a tracking branch other than master
# include it in the patch name
tracking_suffix=""
if [[ $tracking_branch != "origin/master" \
&& $tracking_branch != "master" ]]; then
tracking_suffix="-${tracking_branch#origin/}"
fi
patch_name="$branch$prefix$addendum.patch"
patch_name="$branch$prefix$addendum$tracking_suffix.patch"
# Do we need to make a diff?
git diff --quiet $tracking_branch
@ -134,10 +141,10 @@ local_commits=$(git log $tracking_branch..$branch|grep 'Author:'|wc -l|awk {'pri
if [ "$local_commits" -gt 1 ]; then
read -p "$local_commits commits exist only in your local branch. Interactive rebase?" yn
case $yn in
[Yy]* )
[Yy]* )
git rebase -i $tracking_branch
;;
[Nn]* )
[Nn]* )
echo "Creating $patch_dir/$patch_name using git diff."
git diff $tracking_branch > $patch_dir/$patch_name
exit 0
@ -147,5 +154,3 @@ fi
echo "Creating patch $patch_dir/$patch_name using git format-patch"
git format-patch --stdout $tracking_branch > $patch_dir/$patch_name