mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
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>
This commit is contained in:
parent
e39bb8cd12
commit
65c2d1eb82
|
@ -2,15 +2,13 @@
|
||||||
ODIR=pull-$$
|
ODIR=pull-$$
|
||||||
RELATIVE_TO="master"
|
RELATIVE_TO="master"
|
||||||
COMMIT_ID="HEAD"
|
COMMIT_ID="HEAD"
|
||||||
PULL_URL="git://git.openembedded.org/openembedded-core-contrib"
|
|
||||||
WEB_URL_PREFIX="http://git.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h="
|
|
||||||
PREFIX="PATCH"
|
PREFIX="PATCH"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
CMD=$(basename $0)
|
CMD=$(basename $0)
|
||||||
cat <<EOM
|
cat <<EOM
|
||||||
Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -b contrib_branch
|
Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -u remote -b branch
|
||||||
-b contrib_branch Branch-name in the $PULL_URL
|
-b branch Branch name in the specified remote
|
||||||
-h Display this help message
|
-h Display this help message
|
||||||
-i commit_id Ending commit (default: HEAD)
|
-i commit_id Ending commit (default: HEAD)
|
||||||
-m msg_body_file The file containing a blurb to be inserted into the summary email
|
-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
|
||||||
-p prefix Use [prefix N/M] instead of [PATCH N/M] as the subject prefix
|
-p prefix Use [prefix N/M] instead of [PATCH N/M] as the subject prefix
|
||||||
-r relative_to Starting commit (default: master)
|
-r relative_to Starting commit (default: master)
|
||||||
-s subject The subject to be inserted into the summary email
|
-s subject The subject to be inserted into the summary email
|
||||||
|
-u remote The git remote where the branch is located
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
$CMD -b nitin/basic
|
$CMD -u contrib -b nitin/basic
|
||||||
$CMD -r distro/master -i nitin/distro -b nitin/distro
|
$CMD -u contrib -r distro/master -i nitin/distro -b nitin/distro
|
||||||
$CMD -r master -i misc -b nitin/misc -o pull-misc
|
$CMD -u contrib -r master -i misc -b nitin/misc -o pull-misc
|
||||||
$CMD -p "RFC PATCH" -b nitin/experimental
|
$CMD -u contrib -p "RFC PATCH" -b nitin/experimental
|
||||||
EOM
|
EOM
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse and validate arguments
|
# Parse and validate arguments
|
||||||
while getopts "b:hi:m:o:p:r:s:" OPT; do
|
while getopts "b:hi:m:o:p:r:s:u:" OPT; do
|
||||||
case $OPT in
|
case $OPT in
|
||||||
b)
|
b)
|
||||||
CONTRIB_BRANCH="$OPTARG"
|
BRANCH="$OPTARG"
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
|
@ -59,23 +58,45 @@ while getopts "b:hi:m:o:p:r:s:" OPT; do
|
||||||
s)
|
s)
|
||||||
SUBJECT="$OPTARG"
|
SUBJECT="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
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'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
|
||||||
|
# The .git suffix is optional in the URL, drop in for the REPO
|
||||||
|
REMOTE_REPO=${REMOTE_REPO%.git}
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$CONTRIB_BRANCH" ]; then
|
if [ -z "$BRANCH" ] || [ -z "$REMOTE_URL" ]; then
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Set WEB_URL from known remotes
|
||||||
|
case "$REMOTE_URL" in
|
||||||
|
*git.yoctoproject.org*)
|
||||||
|
WEB_URL="http://git.yoctoproject.org/cgit.cgi/$REMOTE_REPO/log/?h=$BRANCH"
|
||||||
|
;;
|
||||||
|
*git.pokylinux.org*)
|
||||||
|
WEB_URL="http://git.pokylinux.org/cgit.cgi/$REMOTE_REPO/log/?h=$BRANCH"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Perform a sanity test on the web URL. Issue a warning if it is not
|
# Perform a sanity test on the web URL. Issue a warning if it is not
|
||||||
# accessible, but do not abort as users may want to run offline.
|
# accessible, but do not abort as users may want to run offline.
|
||||||
WEB_URL="$WEB_URL_PREFIX$CONTRIB_BRANCH"
|
if [ -n "$WEB_URL" ]; then
|
||||||
wget -q $WEB_URL -O /dev/null
|
wget -q $WEB_URL -O /dev/null
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "WARNING: Branch '$CONTRIB_BRANCH' was not found on the contrib git tree."
|
echo "WARNING: Branch '$BRANCH' was not found on the contrib git tree."
|
||||||
echo " Please check your contrib-branch parameter before sending."
|
echo " Please check your remote and branch parameter before sending."
|
||||||
echo ""
|
echo ""
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e $ODIR ]; then
|
if [ -e $ODIR ]; then
|
||||||
|
@ -91,18 +112,23 @@ git format-patch -M --subject-prefix="$PREFIX" -n -o $ODIR --thread=shallow --co
|
||||||
|
|
||||||
# Customize the cover letter
|
# Customize the cover letter
|
||||||
CL="$ODIR/0000-cover-letter.patch"
|
CL="$ODIR/0000-cover-letter.patch"
|
||||||
(cat <<EOM
|
PM="$ODIR/pull-msg"
|
||||||
|
git request-pull $RELATIVE_TO $REMOTE_URL $COMMIT_ID > "$PM"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "ERROR: git request-pull reported an error"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
Pull URL: $PULL_URL
|
# The cover letter already has a diffstat, remove it from the pull-msg
|
||||||
Branch: $CONTRIB_BRANCH
|
# before inserting it.
|
||||||
Browse: $WEB_URL
|
sed -n "0,\#$REMOTE_URL# p" "$PM" | sed -i "/BLURB HERE/ r /dev/stdin" "$CL"
|
||||||
|
rm "$PM"
|
||||||
|
|
||||||
Thanks,
|
# Insert the WEB_URL if there is one
|
||||||
$(git config user.name) <$(git config user.email)>
|
if [ -n "$WEB_URL" ]; then
|
||||||
---
|
echo " $WEB_URL" | sed -i "\#$REMOTE_URL# r /dev/stdin" "$CL"
|
||||||
|
fi
|
||||||
|
|
||||||
EOM
|
|
||||||
) | sed -i "/BLURB HERE/ r /dev/stdin" "$CL"
|
|
||||||
|
|
||||||
# If the user specified a message body, insert it into the cover letter and
|
# If the user specified a message body, insert it into the cover letter and
|
||||||
# remove the BLURB token.
|
# remove the BLURB token.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user