From b9e94c05c3c087079fa6631e37c0e50ccc05988b Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Tue, 15 Sep 2026 19:41:30 -1000 Subject: Apply the mailmap at HEAD to every ident --- tests/t0208-mailmap.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 tests/t0208-mailmap.sh (limited to 'tests/t0208-mailmap.sh') 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 " >.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 -- cgit v2.8.0