Diff options
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0208-mailmap.sh | 114 |
1 file changed, 83 insertions, 31 deletions
diff --git a/tests/t0208-mailmap.sh b/tests/t0208-mailmap.sh index 9e9ae0f..ceb9b0f 100755 --- a/tests/t0208-mailmap.sh +++ b/tests/t0208-mailmap.sh @@ -1,14 +1,20 @@ #!/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. +# .mailmap at HEAD renaming it, and every page that shows an ident is checked +# for the new name, along with the author search. Only that blob is read, so +# a mailmap set in the repository's config or kept on another branch is +# checked to change nothing. 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 +# The last commit is by the old ident and stamped now, so the stats page, +# which counts only recent periods, has it to show. The side branch holds a +# mailmap of its own, and the repository config points at two more, all of +# which cgit leaves alone. test_expect_success 'create a repository with a mailmap at its head' ' test_create_repo repos/mapped && ( @@ -16,71 +22,117 @@ test_expect_success 'create a repository with a mailmap at its head' ' echo content >file && git add file && GIT_AUTHOR_NAME="Old Name" GIT_AUTHOR_EMAIL=old@example.com \ + GIT_COMMITTER_NAME="Old Name" GIT_COMMITTER_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 && + git checkout -b side && + echo "Branch Name <branch@example.com> <old@example.com>" >.mailmap && + git add .mailmap && + git commit -m "a mailmap of its own" && + git checkout - && echo "New Name <new@example.com> <old@example.com>" >.mailmap && git add .mailmap && - git commit -m "add the mailmap" - ) + git commit -m "add the mailmap" && + echo "Leaked Blob <blob@example.com> <committer@example.com>" >other.mailmap && + git add other.mailmap && + git commit -m "add another mailmap" && + echo "Leaked File <file@example.com> <committer@example.com>" >../file.mailmap && + git config mailmap.file "$(pwd)/../file.mailmap" && + git config mailmap.blob HEAD:other.mailmap && + unset GIT_AUTHOR_DATE GIT_COMMITTER_DATE && + GIT_AUTHOR_NAME="Old Name" GIT_AUTHOR_EMAIL=old@example.com \ + git commit --allow-empty -m "fresh commit" + ) && + cgitrc_repo mappedrc mapped ' -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_ok mappedrc "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 log shows the mapped author' ' - cgit_url "mapped/log/" >tmp && +test_expect_success 'so does the summary' ' + cgit_ok mappedrc "url=mapped/" >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 && +test_expect_success 'the commit page maps both the author and the committer' ' + first=$(git -C repos/mapped rev-parse HEAD~3) && + cgit_ok mappedrc "url=mapped/commit/&id=$first" >tmp && grep "<th scope=.row.>author</th><td>New Name <new@example.com></td>" tmp && + grep "<th scope=.row.>committer</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 && + cgit_ok mappedrc "url=mapped/tag/&h=v1" >tmp && + grep "<tr><th scope=.row.>tagged by</th><td>New Name <new@example.com></td></tr>" tmp && ! grep "Old Name" tmp ' test_expect_success 'the atom feed uses the mapped name and address' ' - cgit_url "mapped/atom/" >tmp && + cgit_ok mappedrc "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_url "mapped/log/&qt=author&q=New+Name" >tmp && +test_expect_success 'the blame page shows the mapped author' ' + cgitrc_repo blamerc mapped enable-blame=1 && + cgit_ok blamerc "url=mapped/blame/file" >tmp && + grep "title=.author New Name <new@example.com> " tmp && + ! grep "Old Name" tmp +' + +test_expect_success 'the stats page counts the mapped author' ' + cgitrc_repo statsrc mapped max-stats=year && + cgit_ok statsrc "url=mapped/stats/&period=y" >tmp && + grep "<td class=.left.>New Name</td>" tmp && + ! grep "Old Name" tmp +' + +test_expect_success 'the author search matches the mapped name alone' ' + cgit_ok mappedrc "url=mapped/log/&qt=author&q=New+Name" >tmp && grep ">first commit</a>" tmp && - cgit_url "mapped/log/&qt=author&q=Nobody" >tmp && + cgit_ok mappedrc "url=mapped/log/&qt=author&q=Old+Name" >tmp && + grep "No commits match the search" tmp && + ! grep ">first commit</a>" tmp && + cgit_ok mappedrc "url=mapped/log/&qt=author&q=Nobody" >tmp && + grep "No commits match the search" tmp && ! grep ">first commit</a>" tmp ' +test_expect_success 'a mailmap anywhere but the blob at HEAD changes nothing' ' + cgit_ok mappedrc "url=mapped/log/&h=side" >tmp && + grep "<td class=.col-author.>New Name</td>" tmp && + ! grep "Branch Name" tmp && + first=$(git -C repos/mapped rev-parse HEAD~3) && + cgit_ok mappedrc "url=mapped/commit/&id=$first" >tmp && + grep "<th scope=.row.>committer</th><td>New Name" tmp && + cgit_ok mappedrc "url=mapped/commit/" >tmp && + grep "<th scope=.row.>committer</th><td>C O Mitter <committer@example.com></td>" tmp && + ! grep "Leaked" tmp +' + test_expect_success 'with the flag off the old ident shows' ' - { - echo "enable-mailmap=0" && - cat cgitrc - } >cgitrc-off && - cgit_rc cgitrc-off "url=mapped/log/" >tmp && + cgitrc_repo offrc mapped enable-mailmap=0 && + cgit_ok offrc "url=mapped/log/" >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 + cgitrc_repo repooffrc mapped repo.enable-mailmap=0 && + cgit_ok repooffrc "url=mapped/log/" >tmp && + grep "<td class=.col-author.>Old Name</td>" tmp && + cgitrc_repo repoonrc mapped enable-mailmap=0 repo.enable-mailmap=1 && + cgit_ok repoonrc "url=mapped/log/" >tmp && + grep "<td class=.col-author.>New Name</td>" tmp && + ! grep "Old Name" tmp ' test_done |
