]> code.ossystems Code Review - openembedded-core.git/commitdiff
create-pull-request: Assume remote branch from local branch
authorDarren Hart <dvhart@linux.intel.com>
Thu, 5 Apr 2012 21:24:43 +0000 (14:24 -0700)
committerSaul Wold <sgw@linux.intel.com>
Tue, 10 Apr 2012 07:20:47 +0000 (00:20 -0700)
It is common to use the same remote branch name as the local branch
name. In this case, it would be nice not to have to specify the
remote branch name.

Make the -b argument optional and assume the remote branch is the same
name as the local branch. Print a NOTE to this effect so as not to
catch the user by surprise:

NOTE: Assuming remote branch 'notthere', use -b to override.

If the remote branch doesn't exist, a WARNING is displayed just as if
the user had used -b to specify a non-existent branch:

WARNING: Branch 'notthere' was not found on the contrib git tree.
         Please check your remote and branch parameter before sending.

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
scripts/create-pull-request

index 600fa7a341fdaf1930e99fa62daadbd6ab086164..9a8913db72bbb7443e9d454d9fb6199b3be58e07 100755 (executable)
@@ -34,8 +34,8 @@ RFC=0
 usage() {
 CMD=$(basename $0)
 cat <<EOM
-Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -u remote -b branch
-  -b branch           Branch name in the specified remote
+Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -u remote [-b branch]
+  -b branch           Branch name in the specified remote (default: current branch)
   -c                  Create an RFC (Request for Comment) patch series
   -h                  Display this help message
   -i commit_id        Ending commit (default: HEAD)
@@ -120,7 +120,12 @@ while getopts "b:chi:m:o:p:r:s:u:" OPT; do
        esac
 done
 
-if [ -z "$BRANCH" ] || [ -z "$REMOTE_URL" ]; then
+if [ -z "$BRANCH" ]; then
+       BRANCH=$(git branch | grep -e "^\* " | cut -d' ' -f2)
+       echo "NOTE: Assuming remote branch '$BRANCH', use -b to override."
+fi
+       
+if [ -z "$REMOTE_URL" ]; then
        usage
        exit 1
 fi