1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
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_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" &&
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 '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 '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 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_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_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 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_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' '
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' '
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
|