diff options
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0208-mailmap.sh | 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 86 insertions, 0 deletions
diff --git a/tests/t0208-mailmap.sh b/tests/t0208-mailmap.sh new file mode 100755 index 0000000..ca08de0 --- /dev/null +++ b/tests/t0208-mailmap.sh @@ -0,0 +1,86 @@ +#!/bin/sh + +# The mailmap. A repository whose commits and tag carry an old ident gets a +# .mailmap at HEAD renaming it, and the log, commit, tag, atom and search +# pages are checked for the new name, then the flag is turned off globally and +# for the one repository. + +test_description='Check the mailmap is applied to idents' +CGIT_TEST_NO_CREATE_REPOS=YesPlease +. ./setup.sh + +test_expect_success 'create a repository with a mailmap at its head' ' + test_create_repo repos/mapped && + ( + cd repos/mapped && + echo content >file && + git add file && + GIT_AUTHOR_NAME="Old Name" GIT_AUTHOR_EMAIL=old@example.com \ + git commit -m "first commit" && + GIT_COMMITTER_NAME="Old Name" GIT_COMMITTER_EMAIL=old@example.com \ + git tag -a -m "a tag" v1 && + echo "New Name <new@example.com> <old@example.com>" >.mailmap && + git add .mailmap && + git commit -m "add the mailmap" + ) +' + +test_expect_success 'point cgit at it' ' + cat >cgitrc <<-EOF + virtual-root=/ + cache-size=0 + repo.url=mapped + repo.path=$PWD/repos/mapped/.git + EOF +' + +test_expect_success 'the log shows the mapped author' ' + cgit_url "mapped/log/" >tmp && + grep ">first commit</a>" tmp && + grep "<td class=.col-author.>New Name</td>" tmp && + ! grep "Old Name" tmp +' + +test_expect_success 'the commit page shows the mapped author and address' ' + first=$(git -C repos/mapped rev-parse HEAD~1) && + cgit_url "mapped/commit/&id=$first" >tmp && + grep "<th>author</th><td>New Name <new@example.com></td>" tmp && + ! grep "old@example.com" tmp +' + +test_expect_success 'the tag page shows the mapped tagger' ' + cgit_url "mapped/tag/&h=v1" >tmp && + grep "New Name <new@example.com>" tmp && + ! grep "Old Name" tmp +' + +test_expect_success 'the atom feed uses the mapped name and address' ' + cgit_url "mapped/atom/" >tmp && + grep "<name>New Name</name>" tmp && + grep "<email>new@example.com</email>" tmp && + ! grep "Old Name" tmp +' + +test_expect_success 'the author search matches the mapped name' ' + cgit_query "url=mapped/log/&qt=author&q=New+Name" >tmp && + grep ">first commit</a>" tmp && + cgit_query "url=mapped/log/&qt=author&q=Nobody" >tmp && + ! grep ">first commit</a>" tmp +' + +test_expect_success 'with the flag off the old ident shows' ' + { + echo "enable-mailmap=0" && + cat cgitrc + } >cgitrc-off && + CGIT_CONFIG="$PWD/cgitrc-off" QUERY_STRING="url=mapped/log/" cgit >tmp && + grep "<td class=.col-author.>Old Name</td>" tmp +' + +test_expect_success 'the repository flag overrides the global one' ' + echo "repo.enable-mailmap=0" >>cgitrc && + cgit_url "mapped/log/" >tmp && + grep "<td class=.col-author.>Old Name</td>" tmp +' + +test_done |
