git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 3/7] t9001-send-email: refactor header variable fields replacement

From
Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>
Date
Jun 9, 2015, 17:56 UTC
Message-ID
<1433872587-15515-4-git-send-email-remi.lespinet@ensimag.grenoble-inp.fr>
In-Reply-To
<1433872587-15515-1-git-send-email-remi.lespinet@ensimag.grenoble-inp.fr>

Create a function which replaces Date, Message-Id and X-Mailer lines generated by git-send-email by a specific string

Date:.*$ -> Date: DATE-STRING Message-Id:.*$ -> Message-Id: MESSAGE-ID-STRING X-Mailer:.*$ -> X-Mailer: X-MAILER-STRING

This is a preparatory for the next commit.
Signed-off-by: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>
---
 t/t9001-send-email.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 062c703..806f066 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -522,6 +522,12 @@ Result: OK
 EOF
 "
 
+replace_variable_fields () {
+	sed	-e "s/^\(Date:\).*/\1 DATE-STRING/" \
+		-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
+		-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/"
+}
+
 test_suppression () {
 	git send-email \
 		--dry-run \
@@ -529,10 +535,7 @@ test_suppression () {
 		--from="Example <from@example.com>" \
 		--to=to@example.com \
 		--smtp-server relay.example.com \
-		$patches |
-	sed	-e "s/^\(Date:\).*/\1 DATE-STRING/" \
-		-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
-		-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
+		$patches | replace_variable_fields \
 		>actual-suppress-$1${2+"-$2"} &&
 	test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
 }
-- 
1.9.1
Previous: Remi LespinetNext: Remi Lespinet
Message 4 of 8 in “changes from last version”
  1. 0/7 changes from last versionRemi Lespinet, Jun 9, 2015
  2. 1/7 t9001-send-email: move script creation in a setup testRemi Lespinet, Jun 9, 2015
  3. 2/7 send-email: allow aliases in patch header and command script outputsRemi Lespinet, Jun 9, 2015
  4. 3/7 t9001-send-email: refactor header variable fields replacementRemi Lespinet, Jun 9, 2015
  5. 4/7 send-email: refactor address list processRemi Lespinet, Jun 9, 2015
  6. 5/7 send-email: allow multiple emails using --cc, --to and --bccRemi Lespinet, Jun 9, 2015
  7. Junio C HamanoJun 10, 2015
  8. Matthieu MoyJun 10, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.