summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-01-12 20:18:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-12 22:04:42 (GMT)
commit05b5ff219c22ca8b3abb7fed3e4dcaf41fe46018 (patch)
treeed77f554db01bbaa362c11bf9e023a7d3ae13876 /t
parentf5d79bf7dd6996b96009ac63b350aa047f2d9959 (diff)
downloadgit-05b5ff219c22ca8b3abb7fed3e4dcaf41fe46018.zip
git-05b5ff219c22ca8b3abb7fed3e4dcaf41fe46018.tar.gz
git-05b5ff219c22ca8b3abb7fed3e4dcaf41fe46018.tar.bz2
mailmap doc + tests: add better examples & test them
Change the mailmap documentation added in 0925ce4d49 (Add map_user() and clear_mailmap() to mailmap, 2009-02-08) to continue discussing the Jane/Joe example. I think this makes things a lot less confusing as we're building up more complex examples using one set of data which covers all the things we'd like to discuss. Also add tests to assert that what our documentation says is what's actually happening. This is mostly (or entirely) covered by existing tests which I'm not deleting, but having these tests for the synopsis makes it easier to follow-along while reading the tests & docs. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t4203-mailmap.sh88
1 files changed, 88 insertions, 0 deletions
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 5d92880..96ba536 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -419,6 +419,94 @@ test_expect_success 'preserve canonical email case' '
test_cmp expect actual
'
+test_expect_success 'gitmailmap(5) example output: setup' '
+ test_create_repo doc &&
+ test_commit -C doc --author "Joe Developer <joe@example.com>" A &&
+ test_commit -C doc --author "Joe R. Developer <joe@example.com>" B &&
+ test_commit -C doc --author "Jane Doe <jane@example.com>" C &&
+ test_commit -C doc --author "Jane Doe <jane@laptop.(none)>" D &&
+ test_commit -C doc --author "Jane D. <jane@desktop.(none)>" E
+'
+
+test_expect_success 'gitmailmap(5) example output: example #1' '
+ test_config -C doc mailmap.file ../doc.map &&
+ cat >doc.map <<-\EOF &&
+ Joe R. Developer <joe@example.com>
+ Jane Doe <jane@example.com>
+ Jane Doe <jane@desktop.(none)>
+ EOF
+
+ cat >expect <<-\EOF &&
+ Author Joe Developer <joe@example.com> maps to Joe R. Developer <joe@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+ Author Joe R. Developer <joe@example.com> maps to Joe R. Developer <joe@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+ Author Jane Doe <jane@example.com> maps to Jane Doe <jane@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+ Author Jane Doe <jane@laptop.(none)> maps to Jane Doe <jane@laptop.(none)>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+ Author Jane D <jane@desktop.(none)> maps to Jane Doe <jane@desktop.(none)>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+ EOF
+ git -C doc log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'gitmailmap(5) example output: example #2' '
+ test_config -C doc mailmap.file ../doc.map &&
+ cat >doc.map <<-\EOF &&
+ Joe R. Developer <joe@example.com>
+ Jane Doe <jane@example.com> <jane@laptop.(none)>
+ Jane Doe <jane@example.com> <jane@desktop.(none)>
+ EOF
+
+ cat >expect <<-\EOF &&
+ Author Joe Developer <joe@example.com> maps to Joe R. Developer <joe@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+ Author Joe R. Developer <joe@example.com> maps to Joe R. Developer <joe@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+ Author Jane Doe <jane@example.com> maps to Jane Doe <jane@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+ Author Jane Doe <jane@laptop.(none)> maps to Jane Doe <jane@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+ Author Jane D <jane@desktop.(none)> maps to Jane Doe <jane@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+ EOF
+ git -C doc log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'gitmailmap(5) example output: example #3' '
+ test_config -C doc mailmap.file ../doc.map &&
+ cat >>doc.map <<-\EOF &&
+ Joe R. Developer <joe@example.com> Joe <bugs@example.com>
+ Jane Doe <jane@example.com> Jane <bugs@example.com>
+ EOF
+
+ test_commit -C doc --author "Joe <bugs@example.com>" F &&
+ test_commit -C doc --author "Jane <bugs@example.com>" G &&
+
+ cat >>expect <<-\EOF &&
+
+ Author Joe <bugs@example.com> maps to Joe R. Developer <joe@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+
+ Author Jane <bugs@example.com> maps to Jane Doe <jane@example.com>
+ Committer C O Mitter <committer@example.com> maps to C O Mitter <committer@example.com>
+ EOF
+ git -C doc log --reverse --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
+ test_cmp expect actual
+'
+
+
test_expect_success 'Shortlog output (complex mapping)' '
test_config mailmap.file complex.map &&
cat >complex.map <<-EOF &&