#!/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 " >.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" tmp && grep "New Name" 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 "authorNew Name <new@example.com>" 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 "New Name" tmp && grep "new@example.com" 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" tmp && cgit_query "url=mapped/log/&qt=author&q=Nobody" >tmp && ! grep ">first commit" 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 "Old Name" tmp ' test_expect_success 'the repository flag overrides the global one' ' echo "repo.enable-mailmap=0" >>cgitrc && cgit_url "mapped/log/" >tmp && grep "Old Name" tmp ' test_done