summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/create-pull-request78
1 files changed, 52 insertions, 26 deletions
diff --git a/scripts/create-pull-request b/scripts/create-pull-request
index b911a64f33..8f7f767b98 100755
--- a/scripts/create-pull-request
+++ b/scripts/create-pull-request
@@ -2,15 +2,13 @@
2ODIR=pull-$$ 2ODIR=pull-$$
3RELATIVE_TO="master" 3RELATIVE_TO="master"
4COMMIT_ID="HEAD" 4COMMIT_ID="HEAD"
5PULL_URL="git://git.openembedded.org/openembedded-core-contrib"
6WEB_URL_PREFIX="http://git.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h="
7PREFIX="PATCH" 5PREFIX="PATCH"
8 6
9usage() { 7usage() {
10CMD=$(basename $0) 8CMD=$(basename $0)
11cat <<EOM 9cat <<EOM
12Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -b contrib_branch 10Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -u remote -b branch
13 -b contrib_branch Branch-name in the $PULL_URL 11 -b branch Branch name in the specified remote
14 -h Display this help message 12 -h Display this help message
15 -i commit_id Ending commit (default: HEAD) 13 -i commit_id Ending commit (default: HEAD)
16 -m msg_body_file The file containing a blurb to be inserted into the summary email 14 -m msg_body_file The file containing a blurb to be inserted into the summary email
@@ -18,20 +16,21 @@ Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to
18 -p prefix Use [prefix N/M] instead of [PATCH N/M] as the subject prefix 16 -p prefix Use [prefix N/M] instead of [PATCH N/M] as the subject prefix
19 -r relative_to Starting commit (default: master) 17 -r relative_to Starting commit (default: master)
20 -s subject The subject to be inserted into the summary email 18 -s subject The subject to be inserted into the summary email
19 -u remote The git remote where the branch is located
21 20
22 Examples: 21 Examples:
23 $CMD -b nitin/basic 22 $CMD -u contrib -b nitin/basic
24 $CMD -r distro/master -i nitin/distro -b nitin/distro 23 $CMD -u contrib -r distro/master -i nitin/distro -b nitin/distro
25 $CMD -r master -i misc -b nitin/misc -o pull-misc 24 $CMD -u contrib -r master -i misc -b nitin/misc -o pull-misc
26 $CMD -p "RFC PATCH" -b nitin/experimental 25 $CMD -u contrib -p "RFC PATCH" -b nitin/experimental
27EOM 26EOM
28} 27}
29 28
30# Parse and validate arguments 29# Parse and validate arguments
31while getopts "b:hi:m:o:p:r:s:" OPT; do 30while getopts "b:hi:m:o:p:r:s:u:" OPT; do
32 case $OPT in 31 case $OPT in
33 b) 32 b)
34 CONTRIB_BRANCH="$OPTARG" 33 BRANCH="$OPTARG"
35 ;; 34 ;;
36 h) 35 h)
37 usage 36 usage
@@ -59,23 +58,45 @@ while getopts "b:hi:m:o:p:r:s:" OPT; do
59 s) 58 s)
60 SUBJECT="$OPTARG" 59 SUBJECT="$OPTARG"
61 ;; 60 ;;
61 u)
62 REMOTE="$OPTARG"
63 REMOTE_URL=$(git config remote.$REMOTE.url)
64 if [ $? -ne 0 ]; then
65 echo "ERROR: git config failed to find a url for '$REMOTE'"
66 exit 1
67 fi
68 REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
69 # The .git suffix is optional in the URL, drop in for the REPO
70 REMOTE_REPO=${REMOTE_REPO%.git}
71 ;;
62 esac 72 esac
63done 73done
64 74
65if [ -z "$CONTRIB_BRANCH" ]; then 75if [ -z "$BRANCH" ] || [ -z "$REMOTE_URL" ]; then
66 usage 76 usage
67 exit 1 77 exit 1
68fi 78fi
69 79
70 80
81# Set WEB_URL from known remotes
82case "$REMOTE_URL" in
83 *git.yoctoproject.org*)
84 WEB_URL="http://git.yoctoproject.org/cgit.cgi/$REMOTE_REPO/log/?h=$BRANCH"
85 ;;
86 *git.pokylinux.org*)
87 WEB_URL="http://git.pokylinux.org/cgit.cgi/$REMOTE_REPO/log/?h=$BRANCH"
88 ;;
89esac
90
71# Perform a sanity test on the web URL. Issue a warning if it is not 91# Perform a sanity test on the web URL. Issue a warning if it is not
72# accessible, but do not abort as users may want to run offline. 92# accessible, but do not abort as users may want to run offline.
73WEB_URL="$WEB_URL_PREFIX$CONTRIB_BRANCH" 93if [ -n "$WEB_URL" ]; then
74wget -q $WEB_URL -O /dev/null 94 wget -q $WEB_URL -O /dev/null
75if [ $? -ne 0 ]; then 95 if [ $? -ne 0 ]; then
76 echo "WARNING: Branch '$CONTRIB_BRANCH' was not found on the contrib git tree." 96 echo "WARNING: Branch '$BRANCH' was not found on the contrib git tree."
77 echo " Please check your contrib-branch parameter before sending." 97 echo " Please check your remote and branch parameter before sending."
78 echo "" 98 echo ""
99 fi
79fi 100fi
80 101
81if [ -e $ODIR ]; then 102if [ -e $ODIR ]; then
@@ -91,18 +112,23 @@ git format-patch -M --subject-prefix="$PREFIX" -n -o $ODIR --thread=shallow --co
91 112
92# Customize the cover letter 113# Customize the cover letter
93CL="$ODIR/0000-cover-letter.patch" 114CL="$ODIR/0000-cover-letter.patch"
94(cat <<EOM 115PM="$ODIR/pull-msg"
116git request-pull $RELATIVE_TO $REMOTE_URL $COMMIT_ID > "$PM"
117if [ $? -ne 0 ]; then
118 echo "ERROR: git request-pull reported an error"
119 exit 1
120fi
95 121
96Pull URL: $PULL_URL 122# The cover letter already has a diffstat, remove it from the pull-msg
97 Branch: $CONTRIB_BRANCH 123# before inserting it.
98 Browse: $WEB_URL 124sed -n "0,\#$REMOTE_URL# p" "$PM" | sed -i "/BLURB HERE/ r /dev/stdin" "$CL"
125rm "$PM"
99 126
100Thanks, 127# Insert the WEB_URL if there is one
101 $(git config user.name) <$(git config user.email)> 128if [ -n "$WEB_URL" ]; then
102--- 129 echo " $WEB_URL" | sed -i "\#$REMOTE_URL# r /dev/stdin" "$CL"
130fi
103 131
104EOM
105) | sed -i "/BLURB HERE/ r /dev/stdin" "$CL"
106 132
107# If the user specified a message body, insert it into the cover letter and 133# If the user specified a message body, insert it into the cover letter and
108# remove the BLURB token. 134# remove the BLURB token.