HBASE-14871 Allow specifying the base branch for make_patch
This commit is contained in:
parent
857ec2f448
commit
28d1706d96
|
@ -20,18 +20,22 @@
|
||||||
# Make a patch for the current branch based on its tracking branch
|
# Make a patch for the current branch based on its tracking branch
|
||||||
|
|
||||||
# Process args
|
# Process args
|
||||||
while getopts "ahd:" opt; do
|
while getopts "ahd:b:" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
a) addendum='-addendum'
|
a) addendum='-addendum'
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
patch_dir=$OPTARG
|
patch_dir=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
b)
|
||||||
|
tracking_branch=$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\
|
||||||
|
-b - Specify the base branch to diff from. (defaults to the tracking branch or origin master)\n\
|
||||||
-d - specify a patch directory (defaults to ~/patches/)"
|
-d - specify a patch directory (defaults to ~/patches/)"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
@ -53,20 +57,25 @@ if [ "$git_dirty" -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine the tracking branch
|
# Determine the tracking branch if needed.
|
||||||
git log -n 1 origin/$branch > /dev/null 2>&1
|
# If it was passed in from the command line
|
||||||
status=$?
|
# with -b then use dthat no matter what.
|
||||||
if [ "$status" -eq 128 ]; then
|
if [ ! "$tracking_branch" ]; then
|
||||||
# Status 128 means there is no remote branch
|
git log -n 1 origin/$branch > /dev/null 2>&1
|
||||||
tracking_branch='origin/master'
|
status=$?
|
||||||
elif [ "$status" -eq 0 ]; then
|
if [ "$status" -eq 128 ]; then
|
||||||
# Status 0 means there is a remote branch
|
# Status 128 means there is no remote branch
|
||||||
tracking_branch="origin/$branch"
|
tracking_branch='origin/master'
|
||||||
else
|
elif [ "$status" -eq 0 ]; then
|
||||||
echo "Unknown error: $?" >&2
|
# Status 0 means there is a remote branch
|
||||||
exit 1
|
tracking_branch="origin/$branch"
|
||||||
|
else
|
||||||
|
echo "Unknown error: $?" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Deal with invalid or missing $patch_dir
|
# Deal with invalid or missing $patch_dir
|
||||||
if [ ! "$patch_dir" ]; then
|
if [ ! "$patch_dir" ]; then
|
||||||
echo -e "Patch directory not specified. Falling back to ~/patches/."
|
echo -e "Patch directory not specified. Falling back to ~/patches/."
|
||||||
|
|
Loading…
Reference in New Issue