[gnome-continuous-yocto/gnomeostree-3.28-rocko: 1714/8267] create-pull-request: read remote from env var CPR_CONTRIB_REMOTE



commit 1d7228c565b881e2006af562f3dd6a42bec73eea
Author: Robert Yang <liezhi yang windriver com>
Date:   Mon Apr 18 02:33:15 2016 -0700

    create-pull-request: read remote from env var CPR_CONTRIB_REMOTE
    
    So that we don't have specify "-u <contrib>" everytime, and
    CPR_CONTRIB_REMOTE can be overrided by -u.
    
    [YOCTO #9409]
    
    (From OE-Core rev: 81c58fd33e725ce7dba693763646f4c30747bbd5)
    
    Signed-off-by: Robert Yang <liezhi yang windriver com>
    Signed-off-by: Ross Burton <ross burton intel com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 scripts/create-pull-request |   66 ++++++++++++++++++++++---------------------
 1 files changed, 34 insertions(+), 32 deletions(-)
---
diff --git a/scripts/create-pull-request b/scripts/create-pull-request
index a60d5b0..9ea28a1 100755
--- a/scripts/create-pull-request
+++ b/scripts/create-pull-request
@@ -47,7 +47,7 @@ Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to
   -p prefix           Use [prefix N/M] instead of [PATCH N/M] as the subject prefix
   -r relative_to      Starting commit (default: master)
   -s subject          The subject to be inserted into the summary email
-  -u remote           The git remote where the branch is located
+  -u remote           The git remote where the branch is located, or set CPR_CONTRIB_REMOTE in env
   -d relative_dir     Generate patches relative to directory
 
  Examples:
@@ -60,6 +60,7 @@ Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to
 EOM
 }
 
+REMOTE="$CPR_CONTRIB_REMOTE"
 # Parse and validate arguments
 while getopts "b:acd:hi:m:o:p:r:s:u:l:" OPT; do
        case $OPT in
@@ -103,31 +104,6 @@ while getopts "b:acd:hi:m:o:p:r:s:u:l:" OPT; do
                ;;
        u)
                REMOTE="$OPTARG"
-               REMOTE_URL=$(git config remote.$REMOTE.url)
-               if [ $? -ne 0 ]; then
-                       echo "ERROR: git config failed to find a url for '$REMOTE'"
-                       echo
-                       echo "To add a remote url for $REMOTE, use:"
-                       echo "  git config remote.$REMOTE.url <url>"
-                       exit 1
-               fi
-
-               # Rewrite private URLs to public URLs
-               # Determine the repository name for use in the WEB_URL later
-               case "$REMOTE_URL" in
-               *@*)
-                       USER_RE="[A-Za-z0-9_.@][A-Za-z0-9_.@-]*\$\?"
-                       PROTO_RE="[a-z][a-z+]*://"
-                       GIT_RE="\(^\($PROTO_RE\)\?$USER_RE@\)\([^:/]*\)[:/]\(.*\)"
-                       REMOTE_URL=${REMOTE_URL%.git}
-                       REMOTE_REPO=$(echo $REMOTE_URL | sed "s#$GIT_RE#\4#")
-                       REMOTE_URL=$(echo $REMOTE_URL | sed "s#$GIT_RE#git://\3/\4#")
-                       ;;
-               *)
-                       echo "WARNING: Unrecognized remote URL: $REMOTE_URL"
-                       echo "         The pull and browse URLs will likely be incorrect"
-                       ;;
-               esac
                ;;
        a)
                CPR_CONTRIB_AUTO_PUSH="1"
@@ -135,6 +111,38 @@ while getopts "b:acd:hi:m:o:p:r:s:u:l:" OPT; do
        esac
 done
 
+if [ -z "$REMOTE" ]; then
+       echo "ERROR: Missing parameter -u or CPR_CONTRIB_REMOTE in env, no git remote!"
+       usage
+       exit 1
+fi
+
+REMOTE_URL=$(git config remote.$REMOTE.url)
+if [ $? -ne 0 ]; then
+       echo "ERROR: git config failed to find a url for '$REMOTE'"
+       echo
+       echo "To add a remote url for $REMOTE, use:"
+       echo "  git config remote.$REMOTE.url <url>"
+       exit 1
+fi
+
+# Rewrite private URLs to public URLs
+# Determine the repository name for use in the WEB_URL later
+case "$REMOTE_URL" in
+*@*)
+       USER_RE="[A-Za-z0-9_.@][A-Za-z0-9_.@-]*\$\?"
+       PROTO_RE="[a-z][a-z+]*://"
+       GIT_RE="\(^\($PROTO_RE\)\?$USER_RE@\)\([^:/]*\)[:/]\(.*\)"
+       REMOTE_URL=${REMOTE_URL%.git}
+       REMOTE_REPO=$(echo $REMOTE_URL | sed "s#$GIT_RE#\4#")
+       REMOTE_URL=$(echo $REMOTE_URL | sed "s#$GIT_RE#git://\3/\4#")
+       ;;
+*)
+       echo "WARNING: Unrecognized remote URL: $REMOTE_URL"
+       echo "         The pull and browse URLs will likely be incorrect"
+       ;;
+esac
+
 if [ -z "$BRANCH" ]; then
        BRANCH=$(git branch | grep -e "^\* " | cut -d' ' -f2)
        echo "NOTE: Assuming remote branch '$BRANCH', use -b to override."
@@ -145,12 +153,6 @@ if [ -z "$L_BRANCH" ]; then
        echo "NOTE: Assuming local branch HEAD, use -l to override."
 fi
 
-if [ -z "$REMOTE_URL" ]; then
-       echo "ERROR: Missing parameter -u, no git remote!"
-       usage
-       exit 1
-fi
-
 if [ $RFC -eq 1 ]; then
        PREFIX="RFC $PREFIX"
 fi


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]