diff options
author | Darren Hart <dvhart@linux.intel.com> | 2011-05-13 10:44:49 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-05-19 23:40:37 +0100 |
commit | 65c2d1eb82ae191c9498068d424adb3c5bf55400 (patch) | |
tree | 7163d876931b562f685540097d202572be57c829 /scripts | |
parent | e39bb8cd12b80c08605e668049cf682e79ec9ecd (diff) | |
download | poky-65c2d1eb82ae191c9498068d424adb3c5bf55400.tar.gz |
create-pull-request: use git request-pull and arbitrary remotes
Allow for arbitrary remotes via a new -u argument. Remove the hard coded
references to the pokylinux repositories. Create the WEB_URL from known
remotes. Future patches can add additional WEB_URL mappings for remotes
like Git Hub, Gitorious, and kernel.org.
Rather than duplicating the git request-pull command ourselves, just use
the existing one.
(From OE-Core rev: 847fa2542aad8233d31076d8eaf4ba3168a79eae)
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Acked-by: Joshua Lock <josh@linux.intel.com>
Acked-by: Otavio Salvador <otavio@ossystems.com.br>
Acked-by: Tom Rini <tom_rini@mentor.com>
Cc: Tom Rini <tom_rini@mentor.com>
Cc: Martin Jansa <martin.jansa@gmail.com>
Cc: Otavio Salvador <otavio@ossystems.com.br>
Cc: Richard Purdie <richard.purdie@linuxfoundation.org>
Cc: Joshua Lock <josh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/create-pull-request | 78 |
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 @@ | |||
2 | ODIR=pull-$$ | 2 | ODIR=pull-$$ |
3 | RELATIVE_TO="master" | 3 | RELATIVE_TO="master" |
4 | COMMIT_ID="HEAD" | 4 | COMMIT_ID="HEAD" |
5 | PULL_URL="git://git.openembedded.org/openembedded-core-contrib" | ||
6 | WEB_URL_PREFIX="http://git.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=" | ||
7 | PREFIX="PATCH" | 5 | PREFIX="PATCH" |
8 | 6 | ||
9 | usage() { | 7 | usage() { |
10 | CMD=$(basename $0) | 8 | CMD=$(basename $0) |
11 | cat <<EOM | 9 | cat <<EOM |
12 | Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -b contrib_branch | 10 | Usage: $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 |
27 | EOM | 26 | EOM |
28 | } | 27 | } |
29 | 28 | ||
30 | # Parse and validate arguments | 29 | # Parse and validate arguments |
31 | while getopts "b:hi:m:o:p:r:s:" OPT; do | 30 | while 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 |
63 | done | 73 | done |
64 | 74 | ||
65 | if [ -z "$CONTRIB_BRANCH" ]; then | 75 | if [ -z "$BRANCH" ] || [ -z "$REMOTE_URL" ]; then |
66 | usage | 76 | usage |
67 | exit 1 | 77 | exit 1 |
68 | fi | 78 | fi |
69 | 79 | ||
70 | 80 | ||
81 | # Set WEB_URL from known remotes | ||
82 | case "$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 | ;; | ||
89 | esac | ||
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. |
73 | WEB_URL="$WEB_URL_PREFIX$CONTRIB_BRANCH" | 93 | if [ -n "$WEB_URL" ]; then |
74 | wget -q $WEB_URL -O /dev/null | 94 | wget -q $WEB_URL -O /dev/null |
75 | if [ $? -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 | ||
79 | fi | 100 | fi |
80 | 101 | ||
81 | if [ -e $ODIR ]; then | 102 | if [ -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 |
93 | CL="$ODIR/0000-cover-letter.patch" | 114 | CL="$ODIR/0000-cover-letter.patch" |
94 | (cat <<EOM | 115 | PM="$ODIR/pull-msg" |
116 | git request-pull $RELATIVE_TO $REMOTE_URL $COMMIT_ID > "$PM" | ||
117 | if [ $? -ne 0 ]; then | ||
118 | echo "ERROR: git request-pull reported an error" | ||
119 | exit 1 | ||
120 | fi | ||
95 | 121 | ||
96 | Pull 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 | 124 | sed -n "0,\#$REMOTE_URL# p" "$PM" | sed -i "/BLURB HERE/ r /dev/stdin" "$CL" |
125 | rm "$PM" | ||
99 | 126 | ||
100 | Thanks, | 127 | # Insert the WEB_URL if there is one |
101 | $(git config user.name) <$(git config user.email)> | 128 | if [ -n "$WEB_URL" ]; then |
102 | --- | 129 | echo " $WEB_URL" | sed -i "\#$REMOTE_URL# r /dev/stdin" "$CL" |
130 | fi | ||
103 | 131 | ||
104 | EOM | ||
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. |