summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-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
47 -p prefix Use [prefix N/M] instead of [PATCH N/M] as the subject prefix 47 -p prefix Use [prefix N/M] instead of [PATCH N/M] as the subject prefix
48 -r relative_to Starting commit (default: master) 48 -r relative_to Starting commit (default: master)
49 -s subject The subject to be inserted into the summary email 49 -s subject The subject to be inserted into the summary email
50 -u remote The git remote where the branch is located 50 -u remote The git remote where the branch is located, or set CPR_CONTRIB_REMOTE in env
51 -d relative_dir Generate patches relative to directory 51 -d relative_dir Generate patches relative to directory
52 52
53 Examples: 53 Examples:
@@ -60,6 +60,7 @@ Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to
60EOM 60EOM
61} 61}
62 62
63REMOTE="$CPR_CONTRIB_REMOTE"
63# Parse and validate arguments 64# Parse and validate arguments
64while getopts "b:acd:hi:m:o:p:r:s:u:l:" OPT; do 65while getopts "b:acd:hi:m:o:p:r:s:u:l:" OPT; do
65 case $OPT in 66 case $OPT in
@@ -103,31 +104,6 @@ while getopts "b:acd:hi:m:o:p:r:s:u:l:" OPT; do
103 ;; 104 ;;
104 u) 105 u)
105 REMOTE="$OPTARG" 106 REMOTE="$OPTARG"
106 REMOTE_URL=$(git config remote.$REMOTE.url)
107 if [ $? -ne 0 ]; then
108 echo "ERROR: git config failed to find a url for '$REMOTE'"
109 echo
110 echo "To add a remote url for $REMOTE, use:"
111 echo " git config remote.$REMOTE.url <url>"
112 exit 1
113 fi
114
115 # Rewrite private URLs to public URLs
116 # Determine the repository name for use in the WEB_URL later
117 case "$REMOTE_URL" in
118 *@*)
119 USER_RE="[A-Za-z0-9_.@][A-Za-z0-9_.@-]*\$\?"
120 PROTO_RE="[a-z][a-z+]*://"
121 GIT_RE="\(^\($PROTO_RE\)\?$USER_RE@\)\([^:/]*\)[:/]\(.*\)"
122 REMOTE_URL=${REMOTE_URL%.git}
123 REMOTE_REPO=$(echo $REMOTE_URL | sed "s#$GIT_RE#\4#")
124 REMOTE_URL=$(echo $REMOTE_URL | sed "s#$GIT_RE#git://\3/\4#")
125 ;;
126 *)
127 echo "WARNING: Unrecognized remote URL: $REMOTE_URL"
128 echo " The pull and browse URLs will likely be incorrect"
129 ;;
130 esac
131 ;; 107 ;;
132 a) 108 a)
133 CPR_CONTRIB_AUTO_PUSH="1" 109 CPR_CONTRIB_AUTO_PUSH="1"
@@ -135,6 +111,38 @@ while getopts "b:acd:hi:m:o:p:r:s:u:l:" OPT; do
135 esac 111 esac
136done 112done
137 113
114if [ -z "$REMOTE" ]; then
115 echo "ERROR: Missing parameter -u or CPR_CONTRIB_REMOTE in env, no git remote!"
116 usage
117 exit 1
118fi
119
120REMOTE_URL=$(git config remote.$REMOTE.url)
121if [ $? -ne 0 ]; then
122 echo "ERROR: git config failed to find a url for '$REMOTE'"
123 echo
124 echo "To add a remote url for $REMOTE, use:"
125 echo " git config remote.$REMOTE.url <url>"
126 exit 1
127fi
128
129# Rewrite private URLs to public URLs
130# Determine the repository name for use in the WEB_URL later
131case "$REMOTE_URL" in
132*@*)
133 USER_RE="[A-Za-z0-9_.@][A-Za-z0-9_.@-]*\$\?"
134 PROTO_RE="[a-z][a-z+]*://"
135 GIT_RE="\(^\($PROTO_RE\)\?$USER_RE@\)\([^:/]*\)[:/]\(.*\)"
136 REMOTE_URL=${REMOTE_URL%.git}
137 REMOTE_REPO=$(echo $REMOTE_URL | sed "s#$GIT_RE#\4#")
138 REMOTE_URL=$(echo $REMOTE_URL | sed "s#$GIT_RE#git://\3/\4#")
139 ;;
140*)
141 echo "WARNING: Unrecognized remote URL: $REMOTE_URL"
142 echo " The pull and browse URLs will likely be incorrect"
143 ;;
144esac
145
138if [ -z "$BRANCH" ]; then 146if [ -z "$BRANCH" ]; then
139 BRANCH=$(git branch | grep -e "^\* " | cut -d' ' -f2) 147 BRANCH=$(git branch | grep -e "^\* " | cut -d' ' -f2)
140 echo "NOTE: Assuming remote branch '$BRANCH', use -b to override." 148 echo "NOTE: Assuming remote branch '$BRANCH', use -b to override."
@@ -145,12 +153,6 @@ if [ -z "$L_BRANCH" ]; then
145 echo "NOTE: Assuming local branch HEAD, use -l to override." 153 echo "NOTE: Assuming local branch HEAD, use -l to override."
146fi 154fi
147 155
148if [ -z "$REMOTE_URL" ]; then
149 echo "ERROR: Missing parameter -u, no git remote!"
150 usage
151 exit 1
152fi
153
154if [ $RFC -eq 1 ]; then 156if [ $RFC -eq 1 ]; then
155 PREFIX="RFC $PREFIX" 157 PREFIX="RFC $PREFIX"
156fi 158fi