[oe-commits] [openembedded-core] 15/28: create-pull-request: read remote from env var CPR_CONTRIB_REMOTE
git at git.openembedded.org
git at git.openembedded.org
Wed Aug 3 15:00:19 UTC 2016
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit ce5ed64ead58b5586e215c7839a8624278f924ae
Author: Robert Yang <liezhi.yang at windriver.com>
AuthorDate: 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]
Signed-off-by: Robert Yang <liezhi.yang at windriver.com>
Signed-off-by: Ross Burton <ross.burton at intel.com>
---
scripts/create-pull-request | 66 +++++++++++++++++++++++----------------------
1 file 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_. at -]*\$\?"
- 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_. at -]*\$\?"
+ 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
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list