All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] send-email: Add simple email aliases format
@ 2015-05-22  3:35 Allen Hubbe
  2015-05-22  3:37 ` Allen Hubbe
  0 siblings, 1 reply; 2+ messages in thread
From: Allen Hubbe @ 2015-05-22  3:35 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King, Felipe Contreras, Allen Hubbe

This format is more simple than the other alias file formats, so it may
be preferred by some users.  The format is as follows.

	<alias>: <address|alias>[, <address|alias>...]

Aliases are specified one per line.  There is no line splitting.
Anything on a line after and including a `#` symbol is considered a
comment, and is ignored.  Blank lines are ignored.

Example of the 'simple' format:

	alice: Alice W Land <awol@example.com>
	bob: Robert Bobbyton <bob@example.com>
	# this is a comment
	   # this is also a comment
	chloe: chloe@example.com
	abgroup: alice, bob # comment after an alias
	bcgrp: bob, chloe, Other <o@example.com>

Signed-off-by: Allen Hubbe <allenbh@gmail.com>
---

Notes:
    This v3 extends the syntax to allow blank lines, and comments.  The test
    case is extended with comments added to alias file input.
    
    The Documentation/git-send-email.txt is updated with a description of
    the simple format.  A note is added for the other formats, directing
    readers to check the documentation of the email clients for a
    description.

 Documentation/git-send-email.txt |  2 +-
 git-send-email.perl              |  6 +++++-
 t/t9001-send-email.sh            | 24 ++++++++++++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 804554609def..99583c4f8969 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -383,7 +383,7 @@ sendemail.aliasesFile::
 
 sendemail.aliasFileType::
 	Format of the file(s) specified in sendemail.aliasesFile. Must be
-	one of 'mutt', 'mailrc', 'pine', 'elm', or 'gnus'.
+	one of 'mutt', 'mailrc', 'pine', 'elm', 'gnus', or 'simple'.
 
 sendemail.multiEdit::
 	If true (default), a single editor instance will be spawned to edit
diff --git a/git-send-email.perl b/git-send-email.perl
index e1e9b1460ced..25d72e8db8bf 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -515,7 +515,11 @@ my %parse_alias = (
 			       $aliases{$alias} = [ split_addrs($addr) ];
 			  }
 		      } },
-
+	simple => sub { my $fh = shift; while (<$fh>) {
+		if (/^\s*(\S+)\s*:\s*(.+)$/) {
+			my ($alias, $addr) = ($1, $2);
+			$aliases{$alias} = [ split_addrs($addr) ];
+		}}},
 	gnus => sub { my $fh = shift; while (<$fh>) {
 		if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
 			$aliases{$1} = [ $2 ];
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 7be14a4e37f7..bbb73cdf8bec 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1548,6 +1548,30 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
 		2>errors >out &&
 	grep "^!someone@example\.org!$" commandline1
 '
+test_expect_success $PREREQ 'sendemail.aliasfiletype=simple' '
+	clean_fake_sendmail && rm -fr outdir &&
+	git format-patch -1 -o outdir &&
+	{
+		echo "alice: Alice W Land <awol@example.com>"
+		echo "bob: Robert Bobbyton <bob@example.com>"
+		echo "chloe: chloe@example.com"
+		echo "abgroup: alice, bob"
+		echo "bcgrp: bob, chloe, Other <o@example.com>"
+	} >~/.tmp-email-aliases &&
+	git config --replace-all sendemail.aliasesfile \
+		"$(pwd)/.tmp-email-aliases" &&
+	git config sendemail.aliasfiletype simple &&
+	git send-email \
+		--from="Example <nobody@example.com>" \
+		--to=alice --to=bcgrp \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		outdir/0001-*.patch \
+		2>errors >out &&
+	grep "^!awol@example\.com!$" commandline1 &&
+	grep "^!bob@example\.com!$" commandline1 &&
+	grep "^!chloe@example\.com!$" commandline1 &&
+	grep "^!o@example\.com!$" commandline1
+'
 
 do_xmailer_test () {
 	expected=$1 params=$2 &&
-- 
2.3.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] send-email: Add simple email aliases format
  2015-05-22  3:35 [PATCH v3] send-email: Add simple email aliases format Allen Hubbe
@ 2015-05-22  3:37 ` Allen Hubbe
  0 siblings, 0 replies; 2+ messages in thread
From: Allen Hubbe @ 2015-05-22  3:37 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Eric Sunshine, Jeff King, Felipe Contreras, Allen Hubbe

Please ignore v3... this is the same as v2 for some reason.  I will
resend as v4.

On Thu, May 21, 2015 at 11:35 PM, Allen Hubbe <allenbh@gmail.com> wrote:
> This format is more simple than the other alias file formats, so it may
> be preferred by some users.  The format is as follows.
>
>         <alias>: <address|alias>[, <address|alias>...]
>
> Aliases are specified one per line.  There is no line splitting.
> Anything on a line after and including a `#` symbol is considered a
> comment, and is ignored.  Blank lines are ignored.
>
> Example of the 'simple' format:
>
>         alice: Alice W Land <awol@example.com>
>         bob: Robert Bobbyton <bob@example.com>
>         # this is a comment
>            # this is also a comment
>         chloe: chloe@example.com
>         abgroup: alice, bob # comment after an alias
>         bcgrp: bob, chloe, Other <o@example.com>
>
> Signed-off-by: Allen Hubbe <allenbh@gmail.com>
> ---
>
> Notes:
>     This v3 extends the syntax to allow blank lines, and comments.  The test
>     case is extended with comments added to alias file input.
>
>     The Documentation/git-send-email.txt is updated with a description of
>     the simple format.  A note is added for the other formats, directing
>     readers to check the documentation of the email clients for a
>     description.
>
>  Documentation/git-send-email.txt |  2 +-
>  git-send-email.perl              |  6 +++++-
>  t/t9001-send-email.sh            | 24 ++++++++++++++++++++++++
>  3 files changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
> index 804554609def..99583c4f8969 100644
> --- a/Documentation/git-send-email.txt
> +++ b/Documentation/git-send-email.txt
> @@ -383,7 +383,7 @@ sendemail.aliasesFile::
>
>  sendemail.aliasFileType::
>         Format of the file(s) specified in sendemail.aliasesFile. Must be
> -       one of 'mutt', 'mailrc', 'pine', 'elm', or 'gnus'.
> +       one of 'mutt', 'mailrc', 'pine', 'elm', 'gnus', or 'simple'.
>
>  sendemail.multiEdit::
>         If true (default), a single editor instance will be spawned to edit
> diff --git a/git-send-email.perl b/git-send-email.perl
> index e1e9b1460ced..25d72e8db8bf 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -515,7 +515,11 @@ my %parse_alias = (
>                                $aliases{$alias} = [ split_addrs($addr) ];
>                           }
>                       } },
> -
> +       simple => sub { my $fh = shift; while (<$fh>) {
> +               if (/^\s*(\S+)\s*:\s*(.+)$/) {
> +                       my ($alias, $addr) = ($1, $2);
> +                       $aliases{$alias} = [ split_addrs($addr) ];
> +               }}},
>         gnus => sub { my $fh = shift; while (<$fh>) {
>                 if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
>                         $aliases{$1} = [ $2 ];
> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
> index 7be14a4e37f7..bbb73cdf8bec 100755
> --- a/t/t9001-send-email.sh
> +++ b/t/t9001-send-email.sh
> @@ -1548,6 +1548,30 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
>                 2>errors >out &&
>         grep "^!someone@example\.org!$" commandline1
>  '
> +test_expect_success $PREREQ 'sendemail.aliasfiletype=simple' '
> +       clean_fake_sendmail && rm -fr outdir &&
> +       git format-patch -1 -o outdir &&
> +       {
> +               echo "alice: Alice W Land <awol@example.com>"
> +               echo "bob: Robert Bobbyton <bob@example.com>"
> +               echo "chloe: chloe@example.com"
> +               echo "abgroup: alice, bob"
> +               echo "bcgrp: bob, chloe, Other <o@example.com>"
> +       } >~/.tmp-email-aliases &&
> +       git config --replace-all sendemail.aliasesfile \
> +               "$(pwd)/.tmp-email-aliases" &&
> +       git config sendemail.aliasfiletype simple &&
> +       git send-email \
> +               --from="Example <nobody@example.com>" \
> +               --to=alice --to=bcgrp \
> +               --smtp-server="$(pwd)/fake.sendmail" \
> +               outdir/0001-*.patch \
> +               2>errors >out &&
> +       grep "^!awol@example\.com!$" commandline1 &&
> +       grep "^!bob@example\.com!$" commandline1 &&
> +       grep "^!chloe@example\.com!$" commandline1 &&
> +       grep "^!o@example\.com!$" commandline1
> +'
>
>  do_xmailer_test () {
>         expected=$1 params=$2 &&
> --
> 2.3.4
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-22  3:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-22  3:35 [PATCH v3] send-email: Add simple email aliases format Allen Hubbe
2015-05-22  3:37 ` Allen Hubbe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.