From 972dcfcdbfe75dcfeb777150c136576cf1a71e99 Mon Sep 17 00:00:00 2001 From: Tudor Florea Date: Fri, 9 Oct 2015 22:59:03 +0200 Subject: initial commit for Enea Linux 5.0 arm Signed-off-by: Tudor Florea --- scripts/create-pull-request | 240 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100755 scripts/create-pull-request (limited to 'scripts/create-pull-request') diff --git a/scripts/create-pull-request b/scripts/create-pull-request new file mode 100755 index 0000000000..503248bbf0 --- /dev/null +++ b/scripts/create-pull-request @@ -0,0 +1,240 @@ +#!/bin/bash +# +# Copyright (c) 2010-2013, Intel Corporation. +# All Rights Reserved +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +# the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# +# This script is intended to be used to prepare a series of patches +# and a cover letter in an appropriate and consistent format for +# submission to Open Embedded and The Yocto Project, as well as to +# related projects and layers. +# + +ODIR=pull-$$ +RELATIVE_TO="master" +COMMIT_ID="HEAD" +PREFIX="PATCH" +RFC=0 + +usage() { +CMD=$(basename $0) +cat <" + 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_.@-]*\$\?" + 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 + ;; + esac +done + +if [ -z "$BRANCH" ]; then + BRANCH=$(git branch | grep -e "^\* " | cut -d' ' -f2) + echo "NOTE: Assuming remote branch '$BRANCH', use -b 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 + + +# Set WEB_URL from known remotes +WEB_URL="" +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" + ;; + *git.openembedded.org*) + WEB_URL="http://cgit.openembedded.org/cgit.cgi/$REMOTE_REPO/log/?h=$BRANCH" + ;; + *github.com*) + WEB_URL="https://github.com/$REMOTE_REPO/tree/$BRANCH" + ;; +esac + +# 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. +if [ -n "$WEB_URL" ]; then + wget --no-check-certificate -q $WEB_URL -O /dev/null + if [ $? -ne 0 ]; then + echo "WARNING: Branch '$BRANCH' was not found on the contrib git tree." + echo " Please check your remote and branch parameter before sending." + echo "" + fi +fi + +if [ -e $ODIR ]; then + echo "ERROR: output directory $ODIR exists." + exit 1 +fi +mkdir $ODIR + + +# Generate the patches and cover letter +git format-patch -M40 --subject-prefix="$PREFIX" -n -o $ODIR --thread=shallow --cover-letter $RELATIVE_TO..$COMMIT_ID > /dev/null + + +# Customize the cover letter +CL="$ODIR/0000-cover-letter.patch" +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 + +# The cover letter already has a diffstat, remove it from the pull-msg +# before inserting it. +sed -n "0,\#$REMOTE_URL# p" "$PM" | sed -i "/BLURB HERE/ r /dev/stdin" "$CL" +rm "$PM" + +# If this is an RFC, make that clear in the cover letter +if [ $RFC -eq 1 ]; then +(cat <