summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-04-18 02:33:15 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-04 15:05:48 +0100
commit81c58fd33e725ce7dba693763646f4c30747bbd5 (patch)
treea21ba5cd2246abfa4e6e52207dce19085f5534db
parenta569bec9219394703d1c1d9b28dd19bf5b058e7f (diff)
downloadopenembedded-core-contrib-81c58fd33e725ce7dba693763646f4c30747bbd5.tar.gz
openembedded-core-contrib-81c58fd33e725ce7dba693763646f4c30747bbd5.tar.bz2
openembedded-core-contrib-81c58fd33e725ce7dba693763646f4c30747bbd5.zip
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] Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
-rwxr-xr-xscripts/create-pull-request66
1 files changed, 34 insertions, 32 deletions
diff --git a/scripts/create-pull-request b/scripts/create-pull-request
index a60d5b0330..9ea28a1652 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