gnu/175985: [PATCH] Improve send-pr

Christoph Mallon christoph.mallon at gmx.de
Sat Feb 9 14:00:00 UTC 2013


>Number:         175985
>Category:       gnu
>Synopsis:       [PATCH] Improve send-pr
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 09 14:00:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Christoph Mallon
>Release:        
>Organization:
>Environment:


	
>Description:
- Do not delete lines starting with Subject:.
  They are most probably part of a attached git patch.
- Recognize an empty file as a not filled out PR, too.
- Allow attaching files via -- followed by file names.
	
>How-To-Repeat:
	
>Fix:
Please apply the patches.

	

--- 0001-send-pr-Do-not-delete-lines-starting-with-Subject.patch begins here ---
>From 5184b240a473c99e960e3bf91137c6cbe9b87916 Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon at gmx.de>
Date: Thu, 7 Feb 2013 15:27:37 +0100
Subject: [PATCH 1/3] send-pr: Do not delete lines starting with Subject:.

They are most probably part of a attached git patch.
---
 gnu/usr.bin/send-pr/send-pr.sh | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/gnu/usr.bin/send-pr/send-pr.sh b/gnu/usr.bin/send-pr/send-pr.sh
index dee0f48..cafab61 100644
--- a/gnu/usr.bin/send-pr/send-pr.sh
+++ b/gnu/usr.bin/send-pr/send-pr.sh
@@ -528,19 +528,6 @@ while true; do
 done
 
 #
-# Remove the subject field if one is already there.  There's no reason
-# for it to be any different than the synopsis.
-#
-if grep '^Subject:' $TEMP > /dev/null
-then
-  ed -s $TEMP << __EOF__
-/^Subject:/d
-w
-q
-__EOF__
-fi
-
-#
 # Add the subject field with the value of $SYNOPSIS.  We use the To:
 # field as an anchor, which had better be there.
 #
-- 
1.8.1.3
--- 0001-send-pr-Do-not-delete-lines-starting-with-Subject.patch ends here ---

--- 0002-send-pr-Recognize-an-empty-file-as-a-not-filled-out-.patch begins here ---
>From 1aef69d088167180c2c9e7c7abc55d256afc59db Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon at gmx.de>
Date: Thu, 7 Feb 2013 15:31:48 +0100
Subject: [PATCH 2/3] send-pr: Recognize an empty file as a not filled out PR,
 too.

---
 gnu/usr.bin/send-pr/send-pr.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/usr.bin/send-pr/send-pr.sh b/gnu/usr.bin/send-pr/send-pr.sh
index cafab61..c009a18 100644
--- a/gnu/usr.bin/send-pr/send-pr.sh
+++ b/gnu/usr.bin/send-pr/send-pr.sh
@@ -393,7 +393,7 @@ __EOF__
   chmod u+w $TEMP
   eval $EDIT $TEMP
 
-  if cmp -s $REF $TEMP ; then
+  if [ ! -s "$TEMP" ] || cmp -s $REF $TEMP ; then
     echo "$COMMAND: problem report not filled out, therefore not sent"
     xs=1; exit
   fi
-- 
1.8.1.3
--- 0002-send-pr-Recognize-an-empty-file-as-a-not-filled-out-.patch ends here ---

--- 0003-send-pr-Allow-attaching-files-via-followed-by-file-n.patch begins here ---
>From fe33d1d033e98bf627d49a111a711ee3c2334872 Mon Sep 17 00:00:00 2001
From: Christoph Mallon <christoph.mallon at gmx.de>
Date: Wed, 6 Feb 2013 15:16:23 +0100
Subject: [PATCH 3/3] send-pr: Allow attaching files via -- followed by file
 names.

---
 gnu/usr.bin/send-pr/send-pr.1  |  6 ++++++
 gnu/usr.bin/send-pr/send-pr.sh | 42 +++++++++++++++++++++++++++---------------
 2 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/gnu/usr.bin/send-pr/send-pr.1 b/gnu/usr.bin/send-pr/send-pr.1
index 49fd42b..4953a50 100644
--- a/gnu/usr.bin/send-pr/send-pr.1
+++ b/gnu/usr.bin/send-pr/send-pr.1
@@ -67,6 +67,12 @@ send-pr \- send problem report (PR) to a central support site
 .B \-a
 .I file
 ]
+[
+--
+[
+.I file...
+]
+]
 .SH DESCRIPTION
 .B send-pr
 is a tool used to submit 
diff --git a/gnu/usr.bin/send-pr/send-pr.sh b/gnu/usr.bin/send-pr/send-pr.sh
index c009a18..07950a7 100644
--- a/gnu/usr.bin/send-pr/send-pr.sh
+++ b/gnu/usr.bin/send-pr/send-pr.sh
@@ -144,6 +144,24 @@ BATCH=
 CC=
 SEVERITY_C=
 
+attach()
+{
+  if [ -e "$1" -a ! -d "$1" ]; then
+    PRETTY_NAME=${1##*/}
+    if file -b "$1" | grep -q "text" 2>/dev/null ; then
+      ATTACHED_FILES="$ATTACHED_FILES
+--- $PRETTY_NAME begins here ---
+$(cat "$1")
+--- $PRETTY_NAME ends here ---
+"
+    else
+      ATTACHED_FILES="$ATTACHED_FILES
+$(uuencode "$PRETTY_NAME" < "$1")
+"
+    fi
+  fi
+}
+
 while [ $# -gt 0 ]; do
   case "$1" in
     -r) ;; 		# Ignore for backward compat.
@@ -173,22 +191,16 @@ while [ $# -gt 0 ]; do
     -a | --attach) if [ -z "$2" ]; then
 	  echo "$USAGE" ; exit 1; 
 	fi
-	if [ -e "$2" -a ! -d "$2" ]; then
-	  PRETTY_NAME=`basename $2`
-	  if file $2 | grep "text" >/dev/null 2>/dev/null ; then
-	    ATTACHED_FILES="$ATTACHED_FILES
---- $PRETTY_NAME begins here ---
-`cat \"$2\"`
---- $PRETTY_NAME ends here ---
-"
-	  else
-	    ATTACHED_FILES="$ATTACHED_FILES
-`uuencode \"$PRETTY_NAME\" < \"$2\"`
-"
-	  fi
-	  shift;
-	fi;
+	attach "$2"
+	shift
 	;;
+    --)
+	shift
+	while [ "$#" != 0 ]; do
+		attach "$1"
+		shift
+	done
+	break;;
     -*) echo "$USAGE" ; exit 1 ;;
     *) if [ -z "$USER_GNATS_SITE" ]; then
 	 if [ ! -r "$DATADIR/gnats/$1" ]; then
-- 
1.8.1.3
--- 0003-send-pr-Allow-attaching-files-via-followed-by-file-n.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list