summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJacob Keller <jacob.keller@gmail.com>2015-11-19 22:52:11 (GMT)
committerJeff King <peff@peff.net>2015-11-20 13:02:06 (GMT)
commit17b7a8324402ab1e5bb66adb287e5463757c9326 (patch)
tree3dcd180aa22323de6b1a902226777284f40e485a /t
parent0c83680e9c047170614fb08ef222ea4f460e514d (diff)
downloadgit-17b7a8324402ab1e5bb66adb287e5463757c9326.zip
git-17b7a8324402ab1e5bb66adb287e5463757c9326.tar.gz
git-17b7a8324402ab1e5bb66adb287e5463757c9326.tar.bz2
sendemail: teach git-send-email to dump alias names
Add an option "--dump-aliases" which changes the default behavior of git-send-email. This mode will simply read the alias files configured by sendemail.aliasesfile and sendemail.aliasfiletype and dump a list of all configured aliases, one per line. The intended use case for this option is the bash-completion script which will use it to autocomplete aliases on the options which take addresses. Add some tests for the new option using various alias file formats. A possible future extension to the alias dump format could be done by extending the --dump-aliases to take an optional argument defining the format to display. This has not been done in this patch as no user of this information has been identified. Signed-off-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 't')
-rwxr-xr-xt/t9001-send-email.sh82
1 files changed, 82 insertions, 0 deletions
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 5b4a5ce..3c49536 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1555,6 +1555,88 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
grep "^!someone@example\.org!$" commandline1
'
+test_dump_aliases () {
+ msg="$1" && shift &&
+ filetype="$1" && shift &&
+ printf '%s\n' "$@" >expect &&
+ cat >.tmp-email-aliases &&
+
+ test_expect_success $PREREQ "$msg" '
+ clean_fake_sendmail && rm -fr outdir &&
+ git config --replace-all sendemail.aliasesfile \
+ "$(pwd)/.tmp-email-aliases" &&
+ git config sendemail.aliasfiletype "$filetype" &&
+ git send-email --dump-aliases 2>errors >actual &&
+ test_cmp expect actual
+ '
+}
+
+test_dump_aliases '--dump-aliases sendmail format' \
+ 'sendmail' \
+ 'abgroup' \
+ 'alice' \
+ 'bcgrp' \
+ 'bob' \
+ 'chloe' <<-\EOF
+ alice: Alice W Land <awol@example.com>
+ bob: Robert Bobbyton <bob@example.com>
+ chloe: chloe@example.com
+ abgroup: alice, bob
+ bcgrp: bob, chloe, Other <o@example.com>
+ EOF
+
+test_dump_aliases '--dump-aliases mutt format' \
+ 'mutt' \
+ 'alice' \
+ 'bob' \
+ 'chloe' \
+ 'donald' <<-\EOF
+ alias alice Alice W Land <awol@example.com>
+ alias donald Donald C Carlton <donc@example.com>
+ alias bob Robert Bobbyton <bob@example.com>
+ alias chloe chloe@example.com
+ EOF
+
+test_dump_aliases '--dump-aliases mailrc format' \
+ 'mailrc' \
+ 'alice' \
+ 'bob' \
+ 'chloe' \
+ 'eve' <<-\EOF
+ alias alice Alice W Land <awol@example.com>
+ alias eve Eve <eve@example.com>
+ alias bob Robert Bobbyton <bob@example.com>
+ alias chloe chloe@example.com
+ EOF
+
+test_dump_aliases '--dump-aliases pine format' \
+ 'pine' \
+ 'alice' \
+ 'bob' \
+ 'chloe' \
+ 'eve' <<-\EOF
+ alice Alice W Land <awol@example.com>
+ eve Eve <eve@example.com>
+ bob Robert Bobbyton <bob@example.com>
+ chloe chloe@example.com
+ EOF
+
+test_dump_aliases '--dump-aliases gnus format' \
+ 'gnus' \
+ 'alice' \
+ 'bob' \
+ 'chloe' \
+ 'eve' <<-\EOF
+ (define-mail-alias "alice" "awol@example.com")
+ (define-mail-alias "eve" "eve@example.com")
+ (define-mail-alias "bob" "bob@example.com")
+ (define-mail-alias "chloe" "chloe@example.com")
+ EOF
+
+test_expect_success '--dump-aliases must be used alone' '
+ test_must_fail git send-email --dump-aliases --to=janice@example.com -1 refs/heads/accounting
+'
+
test_sendmail_aliases () {
msg="$1" && shift &&
expect="$@" &&