Skip to contentSkip to conversation

*-pull-request: cleanup and overhaul

PATCH In review Darren Hart 2 participants 18 messages May 18, 2011

lore
Share & tools
lore
#0 lore raw

v2 cover *-pull-request: cleanup and overhaul

This series was reviewed and received several Acks, now included, and no suggestions for change. It is now ready to be pulled into oe-core. Before merging into the poky/meta dir, poky/meta needs to be synced with oe-core. It is missing the following commit from oe-core:

commit 84e07ef76bf4f484a2d5e0180632e7a4981a1af7

Author: Martin Jansa <[email protected]>
Date:   Tue Mar 15 11:07:22 2011 +0100

create-pull-request: switch URL from git.pokylinux.org/poky-contrib to git.o

The following changes since commit c12126ebf07604f998cb35546aa51d806d97af22:

create-pull-request: switch URL from git.pokylinux.org/poky-contrib to git.openembedded.org/openembedded-core-contrib (2011-05-13 20:38:20 -0700)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib dvhart/git-pull-v2-oe
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=dvhart/git-pull-v2-oe

Darren Hart (13):
create-pull-request: alphabetize arguments
create-pull-request: whitespace cleanup
create-pull-request: use git request-pull and arbitrary remotes
create-pull-request: rewrite known private URLs to public URLs
create-pull-request: provide an RFC mode via -c argument
send-pull-request: whitespace cleanup
send-pull-request: remove local mta support
send-pull-request: fix greedy auto-cc regex
send-pull-request: don't send all patches to everyone even with -a
send-pull-request: verify git sendemail config
create-pull-request: add untested oe repository support
send-pull-request: streamline git-send-email usage *pull-request: add copyright, license, and descriptions

Otavio Salvador (2):
create-pull-request: do not check certificate
create-pull-request: add GitHub remote support

 scripts/create-pull-request |  222 ++++++++++++++++++++++---------
 scripts/send-pull-request   |  307 ++++++++++++++++++++-----------------------
 2 files changed, 302 insertions(+), 227 deletions(-)
#1 lore raw

PATCH v2 1/15 create-pull-request: alphabetize arguments

Some initial cleanup prior to a significant overhaul.

---
 scripts/create-pull-request |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
scripts/create-pull-request +5 -5
index 784b48c..658b9c2 100755
@@ -10,14 +10,14 @@ usage() {
 CMD=$(basename $0)
 cat <<EOM
 Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -b contrib_branch
+  -b contrib_branch   Branch-name in the $PULL_URL
   -h                  Display this help message
-  -o output_dir       Specify the output directory for the messages (default: pull-PID)
+  -i commit_id        Ending commit (default: HEAD)
   -m msg_body_file    The file containing a blurb to be inserted into the summary email
+  -o output_dir       Specify the output directory for the messages (default: pull-PID)
+  -p prefix           Use [prefix N/M] instead of [PATCH N/M] as the subject prefix
   -r relative_to      Starting commit (default: master)
-  -i commit_id        Ending commit (default: HEAD)
-  -b contrib_branch   Branch-name in the $PULL_URL
   -s subject          The subject to be inserted into the summary email
-  -p prefix           Use [prefix N/M] instead of [PATCH N/M] as the subject prefix
 
  Examples:
    $CMD -b nitin/basic
@@ -28,7 +28,7 @@ EOM
 }
 
 # Parse and validate arguments
-while getopts "b:hi:m:o:r:s:p:" OPT; do
+while getopts "b:hi:m:o:p:r:s:" OPT; do
     case $OPT in
     b)
         CONTRIB_BRANCH="$OPTARG"
Signature · 1 line
1.7.1
#2 lore raw

PATCH v2 2/15 create-pull-request: whitespace cleanup

Indent with tabs, not spaces, to be consistent with other bash scripts.

---
 scripts/create-pull-request |   78 +++++++++++++++++++++---------------------
 1 files changed, 39 insertions(+), 39 deletions(-)
scripts/create-pull-request +39 -39
index 658b9c2..b911a64 100755
@@ -29,42 +29,42 @@ EOM
 
 # Parse and validate arguments
 while getopts "b:hi:m:o:p:r:s:" OPT; do
-    case $OPT in
-    b)
-        CONTRIB_BRANCH="$OPTARG"
-        ;;
-    h)
-        usage
-        exit 0
-        ;;
-    i)
-        COMMIT_ID="$OPTARG"
-        ;;
-    m)
-        BODY="$OPTARG"
-        if [ ! -e "$BODY" ]; then
-            echo "ERROR: Body file does not exist"
-            exit 1
-        fi
-        ;;
-    o)
-        ODIR="$OPTARG"
-        ;;
-    p)
-        PREFIX="$OPTARG"
-        ;;
-    r)
-        RELATIVE_TO="$OPTARG"
-        ;;
-    s)
-        SUBJECT="$OPTARG"
-        ;;
-    esac
+	case $OPT in
+	b)
+		CONTRIB_BRANCH="$OPTARG"
+		;;
+	h)
+		usage
+		exit 0
+		;;
+	i)
+		COMMIT_ID="$OPTARG"
+		;;
+	m)
+		BODY="$OPTARG"
+		if [ ! -e "$BODY" ]; then
+			echo "ERROR: Body file does not exist"
+			exit 1
+		fi
+		;;
+	o)
+		ODIR="$OPTARG"
+		;;
+	p)
+		PREFIX="$OPTARG"
+		;;
+	r)
+		RELATIVE_TO="$OPTARG"
+		;;
+	s)
+		SUBJECT="$OPTARG"
+		;;
+	esac
 done
 
 if [ -z "$CONTRIB_BRANCH" ]; then
-    usage
-    exit 1
+	usage
+	exit 1
 fi
 
 
@@ -73,9 +73,9 @@ fi
 WEB_URL="$WEB_URL_PREFIX$CONTRIB_BRANCH"
 wget -q $WEB_URL -O /dev/null
 if [ $? -ne 0 ]; then
-    echo "WARNING: Branch '$CONTRIB_BRANCH' was not found on the contrib git tree."
-    echo "         Please check your contrib-branch parameter before sending."
-    echo ""
+	echo "WARNING: Branch '$CONTRIB_BRANCH' was not found on the contrib git tree."
+	echo "         Please check your contrib-branch parameter before sending."
+	echo ""
 fi
 
 if [ -e $ODIR ]; then
@@ -107,13 +107,13 @@ EOM
 # If the user specified a message body, insert it into the cover letter and
 # remove the BLURB token.
 if [ -n "$BODY" ]; then
-    sed -i "/BLURB HERE/ r $BODY" "$CL"
-    sed -i "/BLURB HERE/ d" "$CL"
+	sed -i "/BLURB HERE/ r $BODY" "$CL"
+	sed -i "/BLURB HERE/ d" "$CL"
 fi
 
 # If the user specified a subject, replace the SUBJECT token with it.
 if [ -n "$SUBJECT" ]; then
-    sed -i -e "s/\*\*\* SUBJECT HERE \*\*\*/$SUBJECT/" "$CL"
+	sed -i -e "s/\*\*\* SUBJECT HERE \*\*\*/$SUBJECT/" "$CL"
 fi
 
 
Signature · 1 line
1.7.1
#3 lore raw

PATCH v2 3/15 create-pull-request: use git request-pull and arbitrary remotes

In reply to Darren Hart

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.

---
 scripts/create-pull-request |   78 ++++++++++++++++++++++++++++--------------
 1 files changed, 52 insertions(+), 26 deletions(-)
scripts/create-pull-request +52 -26
index b911a64..8f7f767 100755
@@ -2,15 +2,13 @@
 ODIR=pull-$$
 RELATIVE_TO="master"
 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"
 
 usage() {
 CMD=$(basename $0)
 cat <<EOM
-Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -b contrib_branch
-  -b contrib_branch   Branch-name in the $PULL_URL
+Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -u remote -b branch
+  -b branch           Branch name in the specified remote
   -h                  Display this help message
   -i commit_id        Ending commit (default: HEAD)
   -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
   -r relative_to      Starting commit (default: master)
   -s subject          The subject to be inserted into the summary email
+  -u remote           The git remote where the branch is located
 
  Examples:
-   $CMD -b nitin/basic
-   $CMD -r distro/master -i nitin/distro -b nitin/distro
-   $CMD -r master -i misc -b nitin/misc -o pull-misc
-   $CMD -p "RFC PATCH" -b nitin/experimental
+   $CMD -u contrib -b nitin/basic
+   $CMD -u contrib -r distro/master -i nitin/distro -b nitin/distro
+   $CMD -u contrib -r master -i misc -b nitin/misc -o pull-misc
+   $CMD -u contrib -p "RFC PATCH" -b nitin/experimental
 EOM
 }
 
 # 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
 	b)
-		CONTRIB_BRANCH="$OPTARG"
+		BRANCH="$OPTARG"
 		;;
 	h)
 		usage
@@ -59,23 +58,45 @@ while getopts "b:hi:m:o:p:r:s:" OPT; do
 	s)
 		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
 done
 
-if [ -z "$CONTRIB_BRANCH" ]; then
+if [ -z "$BRANCH" ] || [ -z "$REMOTE_URL" ]; then
 	usage
 	exit 1
 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
 # accessible, but do not abort as users may want to run offline.
-WEB_URL="$WEB_URL_PREFIX$CONTRIB_BRANCH"
-wget -q $WEB_URL -O /dev/null
-if [ $? -ne 0 ]; then
-	echo "WARNING: Branch '$CONTRIB_BRANCH' was not found on the contrib git tree."
-	echo "         Please check your contrib-branch parameter before sending."
-	echo ""
+if [ -n "$WEB_URL" ]; then
+	wget -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
@@ -91,18 +112,23 @@ git format-patch -M --subject-prefix="$PREFIX" -n -o $ODIR --thread=shallow --co
 
 # Customize the cover letter
 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
-  Branch: $CONTRIB_BRANCH
-  Browse: $WEB_URL
+# 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"
 
-Thanks,
-    $(git config user.name) <$(git config user.email)>
----
+# Insert the WEB_URL if there is one
+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
 # remove the BLURB token.
Signature · 1 line
1.7.1
#4 lore raw

PATCH v2 4/15 create-pull-request: rewrite known private URLs to public URLs

In reply to Darren Hart

Rather than requiring users to have public remotes and private remotes when their development remotes are ssh based (and therefor unsuitable for a pull request URL), rewrite the ones we know about from ssh://git@ to git://.

As the remote url vary from remote to remote, do the REMOTE_REPO regex per remote.

With this infrastructure in place, future patches can augment the list of known remotes for things like Git Hub, Gitorious, kernel.org, etc.

---
 scripts/create-pull-request |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
scripts/create-pull-request +13 -1
index 8f7f767..429421b 100755
@@ -65,7 +65,19 @@ while getopts "b:hi:m:o:p:r:s:u:" OPT; do
 			echo "ERROR: git config failed to find a url for '$REMOTE'"
 			exit 1
 		fi
-		REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
+
+		# Rewrite known private URLs to public URLs
+		# Determine the repository name for use in the WEB_URL later
+		case "$REMOTE_URL" in
+		ssh://[email protected]*)
+			REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
+			REMOTE_URL=${REMOTE_URL/'ssh://git@'/'git://'}
+			;;
+		ssh://[email protected]*)
+			REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
+			REMOTE_URL=${REMOTE_URL/"ssh://git@"/"git://"}
+			;;
+		esac
 		# The .git suffix is optional in the URL, drop in for the REPO
 		REMOTE_REPO=${REMOTE_REPO%.git}
 		;;
Signature · 1 line
1.7.1
#5 lore raw

PATCH v2 5/15 create-pull-request: provide an RFC mode via -c argument

In reply to Darren Hart

Currently it is difficult to know if a pull request is being sent for review or just to be pulled.

Add a -c argument to add RFC to the subject prefix and a blurb requesting review to the cover letter.

---
 scripts/create-pull-request |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)
scripts/create-pull-request +22 -2
index 429421b..202d99d 100755
@@ -3,12 +3,14 @@ ODIR=pull-$$
 RELATIVE_TO="master"
 COMMIT_ID="HEAD"
 PREFIX="PATCH"
+RFC=0
 
 usage() {
 CMD=$(basename $0)
 cat <<EOM
 Usage: $CMD [-h] [-o output_dir] [-m msg_body_file] [-s subject] [-r relative_to] [-i commit_id] -u remote -b branch
   -b branch           Branch name in the specified remote
+  -c                  Create an RFC (Request for Comment) patch series
   -h                  Display this help message
   -i commit_id        Ending commit (default: HEAD)
   -m msg_body_file    The file containing a blurb to be inserted into the summary email
@@ -27,11 +29,14 @@ EOM
 }
 
 # Parse and validate arguments
-while getopts "b:hi:m:o:p:r:s:u:" OPT; do
+while getopts "b:chi:m:o:p:r:s:u:" OPT; do
 	case $OPT in
 	b)
 		BRANCH="$OPTARG"
 		;;
+	c)
+		RFC=1
+		;;
 	h)
 		usage
 		exit 0
@@ -89,6 +94,10 @@ if [ -z "$BRANCH" ] || [ -z "$REMOTE_URL" ]; then
 	exit 1
 fi
 
+if [ $RFC -eq 1 ]; then
+	PREFIX="RFC $PREFIX"
+fi
+
 
 # Set WEB_URL from known remotes
 case "$REMOTE_URL" in
@@ -125,7 +134,7 @@ git format-patch -M --subject-prefix="$PREFIX" -n -o $ODIR --thread=shallow --co
 # Customize the cover letter
 CL="$ODIR/0000-cover-letter.patch"
 PM="$ODIR/pull-msg"
-git request-pull $RELATIVE_TO $REMOTE_URL $COMMIT_ID > "$PM"
+git request-pull $RELATIVE_TO $REMOTE_URL $COMMIT_ID >> "$PM"
 if [ $? -ne 0 ]; then
 	echo "ERROR: git request-pull reported an error"
 	exit 1
@@ -136,6 +145,17 @@ fi
 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 <<EOM
+Please review the following changes for suitability for inclusion. If you have
+any objections or suggestions for improvement, please respond to the patches. If
+you agree with the changes, please provide your Acked-by.
+
+EOM
+) | sed -i "/BLURB HERE/ r /dev/stdin" "$CL"
+fi
+
 # Insert the WEB_URL if there is one
 if [ -n "$WEB_URL" ]; then
 	echo "  $WEB_URL" | sed -i "\#$REMOTE_URL# r /dev/stdin" "$CL"
Signature · 1 line
1.7.1
#6 lore raw

PATCH v2 6/15 send-pull-request: whitespace cleanup

In reply to Darren Hart

Indent with tabs, not spaces, for consistency with other bash scripts.

---
 scripts/send-pull-request |  250 ++++++++++++++++++++++----------------------
 1 files changed, 125 insertions(+), 125 deletions(-)
scripts/send-pull-request +125 -125
index 3af2a9f..76dd7a2 100755
@@ -31,72 +31,72 @@ EOM
 # $2: The regex to match and strip from the line with email addresses
 harvest_recipients()
 {
-    TO_CC=$1
-    REGX=$2
-    export IFS=$',\n'
-    for PATCH in $PDIR/*.patch; do
-        # Grab To addresses
-        for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
-            if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then
-                if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi
-            elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then
-                if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi
-            fi
-        done
-    done
-    unset IFS
+	TO_CC=$1
+	REGX=$2
+	export IFS=$',\n'
+	for PATCH in $PDIR/*.patch; do
+		# Grab To addresses
+		for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
+			if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then
+				if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi
+			elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then
+				if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi
+			fi
+		done
+	done
+	unset IFS
 }
 
 
 # Parse and verify arguments
 while getopts "af:ghp:t:" OPT; do
-    case $OPT in
-        a)
-            AUTO=1
-            ;;
-        f)
-            FROM="$OPTARG"
-            ;;
-        g)
-            PULL_MTA="git"
-            ;;
-        h)
-            usage
-            exit 0
-            ;;
-        p)
-            PDIR=${OPTARG%/}
-            if [ ! -d $PDIR ]; then
-                echo "ERROR: pull-dir \"$PDIR\" does not exist."
-                usage
-                exit 1
-            fi
-            ;;
-        t)
-            if [ -n "$TO" ]; then
-                TO="$TO,$OPTARG"
-            else
-                TO="$OPTARG"
-            fi
-            ;;
-    esac
+	case $OPT in
+	a)
+		AUTO=1
+		;;
+	f)
+		FROM="$OPTARG"
+		;;
+	g)
+		PULL_MTA="git"
+		;;
+	h)
+		usage
+		exit 0
+		;;
+	p)
+		PDIR=${OPTARG%/}
+		if [ ! -d $PDIR ]; then
+			echo "ERROR: pull-dir \"$PDIR\" does not exist."
+			usage
+			exit 1
+		fi
+		;;
+	t)
+		if [ -n "$TO" ]; then
+			TO="$TO,$OPTARG"
+		else
+			TO="$OPTARG"
+		fi
+		;;
+	esac
 done
 
 if [ -z "$PDIR" ]; then
-    echo "ERROR: you must specify a pull-dir."
-    usage
-    exit 1
+	echo "ERROR: you must specify a pull-dir."
+	usage
+	exit 1
 fi
 
 
 # Verify the cover letter is complete and free of tokens
 CL="$PDIR/0000-cover-letter.patch"
 for TOKEN in SUBJECT BLURB; do
-    grep -q "*** $TOKEN HERE ***" "$CL"
-    if [ $? -eq 0 ]; then
-        echo "ERROR: Please edit $CL and try again (Look for '*** $TOKEN HERE ***')."
-        exit 1
-    fi
+	grep -q "*** $TOKEN HERE ***" "$CL"
+	if [ $? -eq 0 ]; then
+		echo "ERROR: Please edit $CL and try again (Look for '*** $TOKEN HERE ***')."
+		exit 1
+	fi
 done
 
 
@@ -104,39 +104,39 @@ done
 # In addition to To and CC headers/lines, the common Signed-off-by, Tested-by,
 # etc. (*-by) will be added to CC.
 if [ $AUTO -eq 1 ]; then
-    harvest_recipients TO "^[Tt][Oo]: *"
-    harvest_recipients CC "^[Cc][Cc]: *"
-    harvest_recipients CC "^.*-[Bb][Yy]: *"
+	harvest_recipients TO "^[Tt][Oo]: *"
+	harvest_recipients CC "^[Cc][Cc]: *"
+	harvest_recipients CC "^.*-[Bb][Yy]: *"
 fi
 
 case "$PULL_MTA" in
-    git)
-        FROM="$(git config sendemail.from)"
+git)
+	FROM="$(git config sendemail.from)"
 	AUTO_TO="$(git config sendemail.to)"
 	if [ -n "$AUTO_TO" ]; then
-	    if [ -n "$TO" ]; then
-		TO="$TO,$AUTO_TO"
-	    else
-		TO="$AUTO_TO"
-	    fi
+		if [ -n "$TO" ]; then
+			TO="$TO,$AUTO_TO"
+		else
+			TO="$AUTO_TO"
+		fi
+	fi
+	;;
+sendmail)
+	if [ -z "$FROM" ]; then
+		FROM="$(git config user.name) <$(git config user.email)>"
+		if [ -z "$FROM" ]; then
+			echo "ERROR: unable to determine a FROM address"
+			usage
+			exit 1
+		fi
 	fi
-        ;;
-    sendmail)
-        if [ -z "$FROM" ]; then
-            FROM="$(git config user.name) <$(git config user.email)>"
-            if [ -z "$FROM" ]; then
-                echo "ERROR: unable to determine a FROM address"
-                usage
-                exit 1
-            fi
-        fi
-        ;;
+	;;
 esac
 
 if [ -z "$TO" ] && [ -z "$CC" ]; then
-    echo "ERROR: you have not specified any recipients."
-    usage
-    exit 1
+	echo "ERROR: you have not specified any recipients."
+	usage
+	exit 1
 fi
 
 
@@ -155,55 +155,55 @@ echo "Continue? [y/N] "
 read cont
 
 if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
-    ERROR=0
-    case "$PULL_MTA" in
-        git)
-            export IFS=$','
-            GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
-            GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
-            unset IFS
-            for PATCH in $PDIR/*patch; do
-                # We harvest the emails manually, so force git not to.
-                eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
-                if [ $? -eq 1 ]; then
-                    ERROR=1
-                fi
-            done
-            ;;
-        sendmail)
-            for PATCH in $PDIR/*patch; do
-                # Insert To and CC headers via formail to keep them separate and
-                # appending them to the sendmail command as -- $TO $CC has
-                # proven to be an exercise in futility.
-                #
-                # Clear the From header, leaving it up to sendmail to insert an
-                # appropriate one. Insert the original sender (per git) into the
-                # body of the message.
-                #
-                # Use tail to remove the email envelope from git or formail as
-                # msmtp (sendmail) would choke on them.
-                #
-                # Modify the patch date for sequential delivery, but retain the
-                # original date as "Old-Date".
-                DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
-                GIT_FROM=$(cat $PATCH | formail -X "From:")
-                cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -I "From: $FROM" -i "Date: $DATE" | sed "0,/^$/s/^$/\n$GIT_FROM\n/" | tail -n +2 | sendmail -t
-                if [ $? -eq 1 ]; then
-                    ERROR=1
-                fi
-            done
-            ;;
-        *)
-            echo "ERROR: unknown MTA: $PULL_MTA"
-            usage
-            exit 1
-            ;;
-    esac
-
-    if [ $ERROR -eq 1 ]; then
-        echo "ERROR: Failed to send one or more messages. Check your MTA log for details."
-    fi
+	ERROR=0
+	case "$PULL_MTA" in
+	git)
+		export IFS=$','
+		GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
+		GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
+		unset IFS
+		for PATCH in $PDIR/*patch; do
+			# We harvest the emails manually, so force git not to.
+			eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
+			if [ $? -eq 1 ]; then
+				ERROR=1
+			fi
+		done
+		;;
+	sendmail)
+		for PATCH in $PDIR/*patch; do
+			# Insert To and CC headers via formail to keep them separate and
+			# appending them to the sendmail command as -- $TO $CC has
+			# proven to be an exercise in futility.
+			#
+			# Clear the From header, leaving it up to sendmail to insert an
+			# appropriate one. Insert the original sender (per git) into the
+			# body of the message.
+			#
+			# Use tail to remove the email envelope from git or formail as
+			# msmtp (sendmail) would choke on them.
+			#
+			# Modify the patch date for sequential delivery, but retain the
+			# original date as "Old-Date".
+			DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
+			GIT_FROM=$(cat $PATCH | formail -X "From:")
+			cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -I "From: $FROM" -i "Date: $DATE" | sed "0,/^$/s/^$/\n$GIT_FROM\n/" | tail -n +2 | sendmail -t
+			if [ $? -eq 1 ]; then
+				ERROR=1
+			fi
+		done
+		;;
+	*)
+		echo "ERROR: unknown MTA: $PULL_MTA"
+		usage
+		exit 1
+		;;
+	esac
+
+	if [ $ERROR -eq 1 ]; then
+		echo "ERROR: Failed to send one or more messages. Check your MTA log for details."
+	fi
 else
-    echo "Send aborted."
+	echo "Send aborted."
 fi
 
Signature · 1 line
1.7.1
#7 lore raw

PATCH v2 7/15 send-pull-request: remove local mta support

In reply to Darren Hart

There is no real value in supporting sendmail directly when git can be configured to use it. The script used to generate the pull request mails relies heavily on git, so doing so here does not impose any additional dependencies and it greatly reduces the complexity of this script.

---
 scripts/send-pull-request |  108 +++++++++------------------------------------
 1 files changed, 21 insertions(+), 87 deletions(-)
scripts/send-pull-request +21 -87
index 76dd7a2..d265c47 100755
@@ -1,15 +1,9 @@
 #!/bin/bash
 AUTO=0
 
-# Check env for any default settings, command line options will override these.
-if [ -z "$PULL_MTA" ]; then
-    PULL_MTA="sendmail"
-fi
-
 # Prevent environment leakage to these vars.
 unset TO
 unset CC
-# allow the user to set FROM in the environment
 
 usage()
 {
@@ -18,10 +12,6 @@ Usage: $(basename $0) [-h] [-a] [[-t email]...] -p pull-dir
   -t email     Explicitly add email to the recipients
   -a           Automatically harvest recipients from "*-by: email" lines
                in the patches in the pull-dir
-  -f           Specify a FROM address, you can also use the FROM environment
-               variable. If you do not specify one, it will try to use the one
-               from your git config. This is ignored if -g is used.
-  -g           Use git-send-email to send mail instead of sendmail
   -p pull-dir  Directory containing summary and patch files
 EOM
 }
@@ -49,17 +39,11 @@ harvest_recipients()
 
 
 # Parse and verify arguments
-while getopts "af:ghp:t:" OPT; do
+while getopts "ahp:t:" OPT; do
 	case $OPT in
 	a)
 		AUTO=1
 		;;
-	f)
-		FROM="$OPTARG"
-		;;
-	g)
-		PULL_MTA="git"
-		;;
 	h)
 		usage
 		exit 0
@@ -109,29 +93,14 @@ if [ $AUTO -eq 1 ]; then
 	harvest_recipients CC "^.*-[Bb][Yy]: *"
 fi
 
-case "$PULL_MTA" in
-git)
-	FROM="$(git config sendemail.from)"
-	AUTO_TO="$(git config sendemail.to)"
-	if [ -n "$AUTO_TO" ]; then
-		if [ -n "$TO" ]; then
-			TO="$TO,$AUTO_TO"
-		else
-			TO="$AUTO_TO"
-		fi
+AUTO_TO="$(git config sendemail.to)"
+if [ -n "$AUTO_TO" ]; then
+	if [ -n "$TO" ]; then
+		TO="$TO,$AUTO_TO"
+	else
+		TO="$AUTO_TO"
 	fi
-	;;
-sendmail)
-	if [ -z "$FROM" ]; then
-		FROM="$(git config user.name) <$(git config user.email)>"
-		if [ -z "$FROM" ]; then
-			echo "ERROR: unable to determine a FROM address"
-			usage
-			exit 1
-		fi
-	fi
-	;;
-esac
+fi
 
 if [ -z "$TO" ] && [ -z "$CC" ]; then
 	echo "ERROR: you have not specified any recipients."
@@ -145,10 +114,7 @@ cat <<EOM
 The following patches:
 $(for PATCH in $PDIR/*.patch; do echo "    $PATCH"; done)
 
-will be sent with the following headers:
-  From: $FROM
-    To: $TO
-    CC: $CC
+will now be sent via the git send-email command.
 
 EOM
 echo "Continue? [y/N] "
@@ -156,52 +122,20 @@ read cont
 
 if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
 	ERROR=0
-	case "$PULL_MTA" in
-	git)
-		export IFS=$','
-		GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
-		GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
-		unset IFS
-		for PATCH in $PDIR/*patch; do
-			# We harvest the emails manually, so force git not to.
-			eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
-			if [ $? -eq 1 ]; then
-				ERROR=1
-			fi
-		done
-		;;
-	sendmail)
-		for PATCH in $PDIR/*patch; do
-			# Insert To and CC headers via formail to keep them separate and
-			# appending them to the sendmail command as -- $TO $CC has
-			# proven to be an exercise in futility.
-			#
-			# Clear the From header, leaving it up to sendmail to insert an
-			# appropriate one. Insert the original sender (per git) into the
-			# body of the message.
-			#
-			# Use tail to remove the email envelope from git or formail as
-			# msmtp (sendmail) would choke on them.
-			#
-			# Modify the patch date for sequential delivery, but retain the
-			# original date as "Old-Date".
-			DATE=$(date +"%a, %d %b %Y %k:%M:%S %z")
-			GIT_FROM=$(cat $PATCH | formail -X "From:")
-			cat $PATCH | formail -I "To: $TO" -I "CC: $CC" -I "From: $FROM" -i "Date: $DATE" | sed "0,/^$/s/^$/\n$GIT_FROM\n/" | tail -n +2 | sendmail -t
-			if [ $? -eq 1 ]; then
-				ERROR=1
-			fi
-		done
-		;;
-	*)
-		echo "ERROR: unknown MTA: $PULL_MTA"
-		usage
-		exit 1
-		;;
-	esac
+	export IFS=$','
+	GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
+	GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
+	unset IFS
+	for PATCH in $PDIR/*patch; do
+		# We harvest the emails manually, so force git not to.
+		eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
+		if [ $? -eq 1 ]; then
+			ERROR=1
+		fi
+	done
 
 	if [ $ERROR -eq 1 ]; then
-		echo "ERROR: Failed to send one or more messages. Check your MTA log for details."
+		echo "ERROR: Failed to send one or more messages."
 	fi
 else
 	echo "Send aborted."
Signature · 1 line
1.7.1
#8 lore raw

PATCH v2 8/15 send-pull-request: fix greedy auto-cc regex

In reply to Darren Hart

A greedy regular expression caused emails to be harvested from patches that were quoted in the commit message. Ensure only tags that start at the beginning of the line are considered for harvesting.

NOTE: users are still responsible for verifying the recipients list and to
ensure they do not spam people!

---
 scripts/send-pull-request |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/send-pull-request +1 -1
index d265c47..b294d35 100755
@@ -90,7 +90,7 @@ done
 if [ $AUTO -eq 1 ]; then
 	harvest_recipients TO "^[Tt][Oo]: *"
 	harvest_recipients CC "^[Cc][Cc]: *"
-	harvest_recipients CC "^.*-[Bb][Yy]: *"
+	harvest_recipients CC "^[A-Z][A-Za-z-]*-[Bb][Yy]: *"
 fi
 
 AUTO_TO="$(git config sendemail.to)"
Signature · 1 line
1.7.1
#9 lore raw

PATCH v2 9/15 send-pull-request: don't send all patches to everyone even with -a

In reply to Darren Hart

Rather than sending every patch to every recipient of the entire series when -a is used, only send the cover letter to everyone and use git's --signed-off-by-cc feature to generate an auto cc list for the individual patches.

Add a -c option to use --signed-off-by-cc to auto cc recipeients at the individual patch level. This is implied by -a.

Using git to harvest the Cc list means only collecting Signed-off-by and Cc lines, rather than the more generic *-by lines previously. This is a fair trade-off for significantly reduced complexity. If users want to add Acked-by and Tested-by lines and want to use the -a feature, they should include those recipients as Cc lines as well.

Now that we rely on git for auto-cc for the individual patches, make sure the user is prompted before sending each patch by forcing --confirm=always.

---
 scripts/send-pull-request |   75 ++++++++++++++++++++++++++++-----------------
 1 files changed, 47 insertions(+), 28 deletions(-)
scripts/send-pull-request +47 -28
index b294d35..5a11d1f 100755
@@ -1,36 +1,40 @@
 #!/bin/bash
 AUTO=0
+AUTO_CL=0
 
 # Prevent environment leakage to these vars.
 unset TO
 unset CC
+unset AUTO_CC
 
 usage()
 {
 cat <<EOM
-Usage: $(basename $0) [-h] [-a] [[-t email]...] -p pull-dir 
-  -t email     Explicitly add email to the recipients
-  -a           Automatically harvest recipients from "*-by: email" lines
-               in the patches in the pull-dir
+Usage: $(basename $0) [-h] [-a] [-c] [[-t email]...] -p pull-dir 
+  -a           Send the cover letter to every recipient listed in Cc and
+               Signed-off-by lines found in the cover letter and the patches.
+	       This option implies -c.
+  -c           Expand the Cc list for the individual patches using the Cc and
+               Signed-off-by lines from the same patch.
   -p pull-dir  Directory containing summary and patch files
+  -t email     Explicitly add email to the recipients
 EOM
 }
 
-# Collect To and CC addresses from the patch files if they exist
-# $1: Which header to add the recipients to, "TO" or "CC"
-# $2: The regex to match and strip from the line with email addresses
+# Collect addresses from a patch into AUTO_CC
+# $1: a patch file
 harvest_recipients()
 {
-	TO_CC=$1
-	REGX=$2
+	PATCH=$1
 	export IFS=$',\n'
-	for PATCH in $PDIR/*.patch; do
-		# Grab To addresses
+	for REGX in "^[Cc][Cc]: *" "^[Ss]igned-[Oo]ff-[Bb]y: *"; do
 		for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
-			if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then
-				if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi
-			elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then
-				if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi
+			if [ "${AUTO_CC/$EMAIL/}" == "$AUTO_CC" ] && [ -n "$EMAIL" ]; then
+				if [ -z "$AUTO_CC" ]; then
+					AUTO_CC=$EMAIL;
+				else
+					AUTO_CC="$AUTO_CC,$EMAIL";
+				fi
 			fi
 		done
 	done
@@ -39,9 +43,13 @@ harvest_recipients()
 
 
 # Parse and verify arguments
-while getopts "ahp:t:" OPT; do
+while getopts "achp:t:" OPT; do
 	case $OPT in
 	a)
+		AUTO_CL=1
+		AUTO=1
+		;;
+	c)
 		AUTO=1
 		;;
 	h)
@@ -84,13 +92,11 @@ for TOKEN in SUBJECT BLURB; do
 done
 
 
-# Harvest emails from the generated patches and populate the TO and CC variables
-# In addition to To and CC headers/lines, the common Signed-off-by, Tested-by,
-# etc. (*-by) will be added to CC.
-if [ $AUTO -eq 1 ]; then
-	harvest_recipients TO "^[Tt][Oo]: *"
-	harvest_recipients CC "^[Cc][Cc]: *"
-	harvest_recipients CC "^[A-Z][A-Za-z-]*-[Bb][Yy]: *"
+# Harvest emails from the generated patches and populate AUTO_CC.
+if [ $AUTO_CL -eq 1 ]; then
+	for PATCH in $PDIR/*.patch; do
+		harvest_recipients $PATCH
+	done
 fi
 
 AUTO_TO="$(git config sendemail.to)"
@@ -102,7 +108,7 @@ if [ -n "$AUTO_TO" ]; then
 	fi
 fi
 
-if [ -z "$TO" ] && [ -z "$CC" ]; then
+if [ -z "$TO" ] && [ -z "$AUTO_CC" ]; then
 	echo "ERROR: you have not specified any recipients."
 	usage
 	exit 1
@@ -114,7 +120,8 @@ cat <<EOM
 The following patches:
 $(for PATCH in $PDIR/*.patch; do echo "    $PATCH"; done)
 
-will now be sent via the git send-email command.
+will now be sent via the git send-email command. Git will prompt you before
+sending any email.
 
 EOM
 echo "Continue? [y/N] "
@@ -124,11 +131,23 @@ if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
 	ERROR=0
 	export IFS=$','
 	GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
-	GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
+	GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done)
 	unset IFS
 	for PATCH in $PDIR/*patch; do
-		# We harvest the emails manually, so force git not to.
-		eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
+		if [ $AUTO -eq 1 ]; then
+			if [ $PATCH == "$CL" ] && [ $AUTO_CL -eq 1 ]; then
+				# Send the cover letter to every recipient, both
+				# specified as well as harvested.
+				eval "git send-email $GIT_TO $GIT_CC --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
+			else
+				# Send the patch to the specified recipients and
+				# those git finds in this specific patch.
+				eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --signed-off-by-cc $PATCH"
+			fi
+		else
+			# Only send to the explicitly specified recipients
+			eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
+		fi
 		if [ $? -eq 1 ]; then
 			ERROR=1
 		fi
Signature · 1 line
1.7.1
Acked-by on v2 9/15
#10 lore raw

Re: [PATCH 09/15] send-pull-request: don't send all patches to everyone even with -a

Quoted 18 lines · Darren Hart

Rather than sending every patch to every recipient of the entire series when -a is used, only send the cover letter to everyone and use git's --signed-off-by-cc feature to generate an auto cc list for the individual patches.

Add a -c option to use --signed-off-by-cc to auto cc recipeients at the individual patch level. This is implied by -a.

Using git to harvest the Cc list means only collecting Signed-off-by and Cc lines, rather than the more generic *-by lines previously. This is a fair trade-off for significantly reduced complexity. If users want to add Acked-by and Tested-by lines and want to use the -a feature, they should include those recipients as Cc lines as well.

Now that we rely on git for auto-cc for the individual patches, make sure the user is prompted before sending each patch by forcing --confirm=always.

Quoted 5 lines

looks good

Quoted 148 lines

---
 scripts/send-pull-request |   75 ++++++++++++++++++++++++++++-----------------

 1 files changed, 47 insertions(+), 28 deletions(-)
scripts/send-pull-request +0 -0
index b294d35..5a11d1f 100755
@@ -1,36 +1,40 @@
  #!/bin/bash

 AUTO=0
+AUTO_CL=0

 # Prevent environment leakage to these vars.
 unset TO
 unset CC
+unset AUTO_CC

 usage()
 {
 cat <<EOM

scripts/send-pull-request +6 -4
-Usage: $(basename $0) [-h] [-a] [[-t email]...] -p pull-dir
-  -t email     Explicitly add email to the recipients
-  -a           Automatically harvest recipients from "*-by: email" lines
-               in the patches in the pull-dir
+Usage: $(basename $0) [-h] [-a] [-c] [[-t email]...] -p pull-dir
+  -a           Send the cover letter to every recipient listed in Cc and
+               Signed-off-by lines found in the cover letter and the patches.
+              This option implies -c.
+  -c           Expand the Cc list for the individual patches using the Cc and
+               Signed-off-by lines from the same patch.

  -p pull-dir  Directory containing summary and patch files
+  -t email     Explicitly add email to the recipients EOM
 }

scripts/send-pull-request +2 -3
-# Collect To and CC addresses from the patch files if they exist
-# $1: Which header to add the recipients to, "TO" or "CC"
-# $2: The regex to match and strip from the line with email addresses
+# Collect addresses from a patch into AUTO_CC
+# $1: a patch file

 harvest_recipients()
 {
-       TO_CC=$1
-       REGX=$2
+       PATCH=$1
       export IFS=$',\n'
-       for PATCH in $PDIR/*.patch; do
-               # Grab To addresses
+       for REGX in "^[Cc][Cc]: *" "^[Ss]igned-[Oo]ff-[Bb]y: *"; do
               for EMAIL in $(sed '/^---$/q' $PATCH | grep -e "$REGX" | sed "s/$REGX//"); do
-                       if [ "$TO_CC" == "TO" ] && [ "${TO/$EMAIL/}" == "$TO" ] && [ -n "$EMAIL" ]; then
-                               if [ -z "$TO" ]; then TO=$EMAIL; else TO="$TO,$EMAIL"; fi
-                       elif [ "$TO_CC" == "CC" ] && [ "${CC/$EMAIL/}" == "$CC" ] && [ -n "$EMAIL" ]; then
-                               if [ -z "$CC" ]; then CC=$EMAIL; else CC="$CC,$EMAIL"; fi
+                       if [ "${AUTO_CC/$EMAIL/}" == "$AUTO_CC" ] && [ -n "$EMAIL" ]; then
+                               if [ -z "$AUTO_CC" ]; then
+                                       AUTO_CC=$EMAIL;
+                               else
+                                       AUTO_CC="$AUTO_CC,$EMAIL";
+                               fi
                       fi
               done
       done

scripts/send-pull-request +1 -1
@@ -39,9 +43,13 @@ harvest_recipients()
 
 
  # Parse and verify arguments
-while getopts "ahp:t:" OPT; do
+while getopts "achp:t:" OPT; do

       case $OPT in
       a)
+               AUTO_CL=1
+               AUTO=1
+               ;;
+       c)
               AUTO=1
               ;;
       h)

scripts/send-pull-request +0 -0
@@ -84,13 +92,11 @@ for TOKEN in SUBJECT BLURB; do

 done

scripts/send-pull-request +5 -7
-# Harvest emails from the generated patches and populate the TO and CC variables
-# In addition to To and CC headers/lines, the common Signed-off-by, Tested-by,
-# etc. (*-by) will be added to CC.
-if [ $AUTO -eq 1 ]; then
-       harvest_recipients TO "^[Tt][Oo]: *"
-       harvest_recipients CC "^[Cc][Cc]: *"
-       harvest_recipients CC "^[A-Z][A-Za-z-]*-[Bb][Yy]: *"
+# Harvest emails from the generated patches and populate AUTO_CC.
+if [ $AUTO_CL -eq 1 ]; then
+       for PATCH in $PDIR/*.patch; do
+               harvest_recipients $PATCH
+       done

 fi

 AUTO_TO="$(git config sendemail.to)"

scripts/send-pull-request +0 -0
@@ -102,7 +108,7 @@ if [ -n "$AUTO_TO" ]; then

       fi
 fi

scripts/send-pull-request +1 -1
-if [ -z "$TO" ] && [ -z "$CC" ]; then
+if [ -z "$TO" ] && [ -z "$AUTO_CC" ]; then

       echo "ERROR: you have not specified any recipients." usage
       exit 1

scripts/send-pull-request +0 -0
@@ -114,7 +120,8 @@ cat <<EOM

 The following patches:
 $(for PATCH in $PDIR/*.patch; do echo "    $PATCH"; done)

scripts/send-pull-request +2 -1
-will now be sent via the git send-email command.
+will now be sent via the git send-email command. Git will prompt you before
+sending any email.

 EOM
 echo "Continue? [y/N] "

scripts/send-pull-request +0 -0
@@ -124,11 +131,23 @@ if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then

       ERROR=0
       export IFS=$','
       GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
-       GIT_CC=$(for R in $CC; do echo -n "--cc='$R' "; done)
+       GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done)
       unset IFS
       for PATCH in $PDIR/*patch; do
-               # We harvest the emails manually, so force git not to.
-               eval "git send-email $GIT_TO $GIT_CC --no-chain-reply-to --suppress-cc=all $PATCH"
+               if [ $AUTO -eq 1 ]; then
+                       if [ $PATCH == "$CL" ] && [ $AUTO_CL -eq 1 ]; then
+                               # Send the cover letter to every recipient, both
+                               # specified as well as harvested.
+                               eval "git send-email $GIT_TO $GIT_CC --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
+                       else
+                               # Send the patch to the specified recipients and
+                               # those git finds in this specific patch.
+                               eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --signed-off-by-cc $PATCH"
+                       fi
+               else
+                       # Only send to the explicitly specified recipients
+                       eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
+               fi
               if [ $? -eq 1 ]; then
                       ERROR=1
               fi
--
1.7.1

#11 lore raw

PATCH v2 10/15 send-pull-request: verify git sendemail config

In reply to Darren Hart

Perform a quick sanity check to be able to direct users to configure git.sendemail if they haven't yet.

---
 scripts/send-pull-request |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
scripts/send-pull-request +15 -0
index 5a11d1f..21eb302 100755
@@ -41,6 +41,18 @@ harvest_recipients()
 	unset IFS
 }
 
+check_git_sendemail_config()
+{
+	GIT_SMTP=$(git config sendemail.smtpserver)
+	GIT_FROM=$(git config sendemail.from)
+	if [ -z "$GIT_SMTP" ] || [ -z "$GIT_FROM" ]; then
+		echo "ERROR: git sendemail is not configured."
+		echo "Please read GIT-SEND-EMAIL(1) and configure:"
+		echo "  sendemail.smtpserver"
+		echo "  sendemail.from"
+		exit 1
+	fi
+}
 
 # Parse and verify arguments
 while getopts "achp:t:" OPT; do
@@ -74,6 +86,9 @@ while getopts "achp:t:" OPT; do
 	esac
 done
 
+# Abort early if git-send-email is not properly configured
+check_git_sendemail_config
+
 if [ -z "$PDIR" ]; then
 	echo "ERROR: you must specify a pull-dir."
 	usage
Signature · 1 line
1.7.1
#12 lore raw

PATCH v2 11/15 create-pull-request: do not check certificate

In reply to Darren Hart

From: Otavio Salvador <[email protected]>

Some remotes can use HTTPS and we don't need to check the certificate of the host so wget call is changed to avoid it.

---
 scripts/create-pull-request |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/create-pull-request +1 -1
index 202d99d..9dbd55a 100755
@@ -112,7 +112,7 @@ 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 -q $WEB_URL -O /dev/null
+	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."
Signature · 1 line
1.7.1
#13 lore raw

PATCH v2 12/15 create-pull-request: add GitHub remote support

In reply to Darren Hart

From: Otavio Salvador <[email protected]>

---
 scripts/create-pull-request |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
scripts/create-pull-request +7 -0
index 9dbd55a..a9cf6f9 100755
@@ -82,6 +82,10 @@ while getopts "b:chi:m:o:p:r:s:u:" OPT; do
 			REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
 			REMOTE_URL=${REMOTE_URL/"ssh://git@"/"git://"}
 			;;
+		[email protected]:*)
+			REMOTE_REPO=$(echo $REMOTE_URL | sed 's#.*:\(.*\)\(\.git\)$#\1#')
+			REMOTE_URL=${REMOTE_URL/"[email protected]:"/"git://github.com/"}
+			;;
 		esac
 		# The .git suffix is optional in the URL, drop in for the REPO
 		REMOTE_REPO=${REMOTE_REPO%.git}
@@ -107,6 +111,9 @@ case "$REMOTE_URL" in
 	*git.pokylinux.org*)
 		WEB_URL="http://git.pokylinux.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
Signature · 1 line
1.7.1
#14 lore raw

PATCH v2 13/15 create-pull-request: add untested oe repository support

In reply to Darren Hart
---
 scripts/create-pull-request |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
scripts/create-pull-request +7 -0
index a9cf6f9..634a289 100755
@@ -82,6 +82,10 @@ while getopts "b:chi:m:o:p:r:s:u:" OPT; do
 			REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
 			REMOTE_URL=${REMOTE_URL/"ssh://git@"/"git://"}
 			;;
+		*ssh://[email protected]*)
+			REMOTE_REPO=$(echo $REMOTE_URL | sed "s#.*/\(.*\)#\1#")
+			REMOTE_URL=${REMOTE_URL/"ssh://git@"/"git://"}
+			;;
 		[email protected]:*)
 			REMOTE_REPO=$(echo $REMOTE_URL | sed 's#.*:\(.*\)\(\.git\)$#\1#')
 			REMOTE_URL=${REMOTE_URL/"[email protected]:"/"git://github.com/"}
@@ -111,6 +115,9 @@ case "$REMOTE_URL" in
 	*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"
 		;;
Signature · 1 line
1.7.1
#15 lore raw

PATCH v2 14/15 send-pull-request: streamline git-send-email usage

In reply to Darren Hart

The script was sending one patch at a time, which defeats the internal confirmation mechanism of git-send-email (which would otherwise allow the user to send all patches or abort immediately).

Rework the sending logic to use no more than two commands. Use two commands when the cover letter is to be sent to all recipients with the -a argument. Otherwise, send all patches via the same command.

The script duplicates git's send confirmation, eliminate that.

---
 scripts/send-pull-request |   68 +++++++++++++++++---------------------------
 1 files changed, 26 insertions(+), 42 deletions(-)
scripts/send-pull-request +26 -42
index 21eb302..8d0bd34 100755
@@ -1,6 +1,7 @@
 #!/bin/bash
 AUTO=0
 AUTO_CL=0
+GITSOBCC=""
 
 # Prevent environment leakage to these vars.
 unset TO
@@ -59,10 +60,11 @@ while getopts "achp:t:" OPT; do
 	case $OPT in
 	a)
 		AUTO_CL=1
-		AUTO=1
-		;;
+		# Fall through to include -c
+		;&
 	c)
 		AUTO=1
+		GITSOBCC="--signed-off-by-cc"
 		;;
 	h)
 		usage
@@ -130,48 +132,30 @@ if [ -z "$TO" ] && [ -z "$AUTO_CC" ]; then
 fi
 
 
-# Generate report for the user and require confirmation before sending
-cat <<EOM
-The following patches:
-$(for PATCH in $PDIR/*.patch; do echo "    $PATCH"; done)
+# Convert the collected addresses into git-send-email argument strings
+export IFS=$','
+GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
+GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done)
+unset IFS
 
-will now be sent via the git send-email command. Git will prompt you before
-sending any email.
 
-EOM
-echo "Continue? [y/N] "
-read cont
-
-if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
-	ERROR=0
-	export IFS=$','
-	GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
-	GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done)
-	unset IFS
-	for PATCH in $PDIR/*patch; do
-		if [ $AUTO -eq 1 ]; then
-			if [ $PATCH == "$CL" ] && [ $AUTO_CL -eq 1 ]; then
-				# Send the cover letter to every recipient, both
-				# specified as well as harvested.
-				eval "git send-email $GIT_TO $GIT_CC --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
-			else
-				# Send the patch to the specified recipients and
-				# those git finds in this specific patch.
-				eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --signed-off-by-cc $PATCH"
-			fi
-		else
-			# Only send to the explicitly specified recipients
-			eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
-		fi
-		if [ $? -eq 1 ]; then
-			ERROR=1
-		fi
-	done
-
-	if [ $ERROR -eq 1 ]; then
-		echo "ERROR: Failed to send one or more messages."
+# Handoff to git-send-email. It will perform the send confirmation.
+PATCHES=$(echo $PDIR/*.patch)
+if [ $AUTO_CL -eq 1 ]; then
+	# Send the cover letter to every recipient, both specified as well as
+	# harvested. Then remove it from the patches list.
+	eval "git send-email $GIT_TO $GIT_CC --confirm=always --no-chain-reply-to --suppress-cc=all $CL"
+	if [ $? -eq 1 ]; then
+		echo "ERROR: failed to send cover-letter with automatic recipients."
+		exit 1
 	fi
-else
-	echo "Send aborted."
+	PATCHES=${PATCHES/"$CL"/}
 fi
 
+# Send the patch to the specified recipients and, if -c was specified, those git
+# finds in this specific patch.
+eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to $GITSOBCC $PATCHES"
+if [ $? -eq 1 ]; then
+	echo "ERROR: failed to send patches."
+	exit 1
+fi
Signature · 1 line
1.7.1
Acked-by on v2 14/15
#16 lore raw

Re: [PATCH 14/15] send-pull-request: streamline git-send-email usage

Quoted 10 lines · Darren Hart

The script was sending one patch at a time, which defeats the internal confirmation mechanism of git-send-email (which would otherwise allow the user to send all patches or abort immediately).

Rework the sending logic to use no more than two commands. Use two commands when the cover letter is to be sent to all recipients with the -a argument. Otherwise, send all patches via the same command.

The script duplicates git's send confirmation, eliminate that.

Quoted 7 lines
Quoted 105 lines

---
 scripts/send-pull-request |   68 +++++++++++++++++---------------------------

 1 files changed, 26 insertions(+), 42 deletions(-)
scripts/send-pull-request +0 -0
index 21eb302..8d0bd34 100755
@@ -1,6 +1,7 @@
  #!/bin/bash

 AUTO=0
 AUTO_CL=0
+GITSOBCC=""

 # Prevent environment leakage to these vars.
 unset TO

scripts/send-pull-request +0 -0
@@ -59,10 +60,11 @@ while getopts "achp:t:" OPT; do

       case $OPT in
       a)
               AUTO_CL=1
-               AUTO=1
-               ;;
+               # Fall through to include -c
+               ;&
       c)
               AUTO=1
+               GITSOBCC="--signed-off-by-cc"
               ;;
       h)
               usage

scripts/send-pull-request +0 -0
@@ -130,48 +132,30 @@ if [ -z "$TO" ] && [ -z "$AUTO_CC" ]; then

 fi

scripts/send-pull-request +14 -38
-# Generate report for the user and require confirmation before sending
-cat <<EOM
-The following patches:
-$(for PATCH in $PDIR/*.patch; do echo "    $PATCH"; done)
+# Convert the collected addresses into git-send-email argument strings
+export IFS=$','
+GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
+GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done)
+unset IFS
 
-will now be sent via the git send-email command. Git will prompt you before
-sending any email.
 
-EOM
-echo "Continue? [y/N] "
-read cont
-
-if [ "$cont" == "y" ] || [ "$cont" == "Y" ]; then
-       ERROR=0
-       export IFS=$','
-       GIT_TO=$(for R in $TO; do echo -n "--to='$R' "; done)
-       GIT_CC=$(for R in $AUTO_CC; do echo -n "--cc='$R' "; done)
-       unset IFS
-       for PATCH in $PDIR/*patch; do
-               if [ $AUTO -eq 1 ]; then
-                       if [ $PATCH == "$CL" ] && [ $AUTO_CL -eq 1 ]; then
-                               # Send the cover letter to every recipient, both
-                               # specified as well as harvested.
-                               eval "git send-email $GIT_TO $GIT_CC --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
-                       else
-                               # Send the patch to the specified recipients and
-                               # those git finds in this specific patch.
-                               eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --signed-off-by-cc $PATCH"
-                       fi
-               else
-                       # Only send to the explicitly specified recipients
-                       eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to --suppress-cc=all $PATCH"
-               fi
-               if [ $? -eq 1 ]; then
-                       ERROR=1
-               fi
-       done
-
-       if [ $ERROR -eq 1 ]; then
-               echo "ERROR: Failed to send one or more messages."
+# Handoff to git-send-email. It will perform the send confirmation.
+PATCHES=$(echo $PDIR/*.patch)
+if [ $AUTO_CL -eq 1 ]; then
+       # Send the cover letter to every recipient, both specified as well as
+       # harvested. Then remove it from the patches list.
+       eval "git send-email $GIT_TO $GIT_CC --confirm=always --no-chain-reply-to --suppress-cc=all $CL"
+       if [ $? -eq 1 ]; then
+               echo "ERROR: failed to send cover-letter with automatic recipients."
+               exit 1

       fi
-else
-       echo "Send aborted."
+       PATCHES=${PATCHES/"$CL"/}
 fi

scripts/send-pull-request +7 -1
+# Send the patch to the specified recipients and, if -c was specified, those git
+# finds in this specific patch.
+eval "git send-email $GIT_TO --confirm=always --no-chain-reply-to $GITSOBCC $PATCHES"
+if [ $? -eq 1 ]; then
+       echo "ERROR: failed to send patches."
+       exit 1
+fi
--

1.7.1

#17 lore raw

PATCH v2 15/15 *pull-request: add copyright, license, and descriptions

In reply to Darren Hart
---
 scripts/create-pull-request |   26 ++++++++++++++++++++++++++
 scripts/send-pull-request   |   25 +++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 0 deletions(-)
scripts/create-pull-request +26 -0
index 634a289..b808146 100755
@@ -1,4 +1,30 @@
 #!/bin/bash
+#
+# Copyright (c) 2010-2011,  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"
scripts/send-pull-request +25 -0
index 8d0bd34..cee9253 100755
@@ -1,4 +1,29 @@
 #!/bin/bash
+#
+# Copyright (c) 2010-2011,  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 send a patch series prepared by the
+# create-pull-request script to Open Embedded and The Yocto Project, as well
+# as to related projects and layers.
+#
+
 AUTO=0
 AUTO_CL=0
 GITSOBCC=""
Signature · 1 line
1.7.1