]>
Commit | Line | Data |
---|---|---|
d551a488 MSO |
1 | #!/bin/sh |
2 | ||
3 | test_description='.mailmap configurations' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success setup ' | |
8 | echo one >one && | |
9 | git add one && | |
10 | test_tick && | |
11 | git commit -m initial && | |
12 | echo two >>one && | |
13 | git add one && | |
14 | git commit --author "nick1 <bugs@company.xx>" -m second | |
15 | ' | |
16 | ||
17 | cat >expect <<\EOF | |
18 | A U Thor (1): | |
19 | initial | |
20 | ||
21 | nick1 (1): | |
22 | second | |
23 | ||
24 | EOF | |
25 | ||
26 | test_expect_success 'No mailmap' ' | |
27 | git shortlog HEAD >actual && | |
28 | test_cmp expect actual | |
29 | ' | |
30 | ||
31 | cat >expect <<\EOF | |
32 | Repo Guy (1): | |
33 | initial | |
34 | ||
35 | nick1 (1): | |
36 | second | |
37 | ||
38 | EOF | |
39 | ||
40 | test_expect_success 'default .mailmap' ' | |
41 | echo "Repo Guy <author@example.com>" > .mailmap && | |
42 | git shortlog HEAD >actual && | |
43 | test_cmp expect actual | |
44 | ' | |
45 | ||
46 | # Using a mailmap file in a subdirectory of the repo here, but | |
47 | # could just as well have been a file outside of the repository | |
48 | cat >expect <<\EOF | |
49 | Internal Guy (1): | |
50 | second | |
51 | ||
52 | Repo Guy (1): | |
53 | initial | |
54 | ||
55 | EOF | |
56 | test_expect_success 'mailmap.file set' ' | |
57 | mkdir internal_mailmap && | |
58 | echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap && | |
59 | git config mailmap.file internal_mailmap/.mailmap && | |
60 | git shortlog HEAD >actual && | |
61 | test_cmp expect actual | |
62 | ' | |
63 | ||
64 | cat >expect <<\EOF | |
65 | External Guy (1): | |
66 | initial | |
67 | ||
68 | Internal Guy (1): | |
69 | second | |
70 | ||
71 | EOF | |
72 | test_expect_success 'mailmap.file override' ' | |
73 | echo "External Guy <author@example.com>" >> internal_mailmap/.mailmap && | |
74 | git config mailmap.file internal_mailmap/.mailmap && | |
75 | git shortlog HEAD >actual && | |
76 | test_cmp expect actual | |
77 | ' | |
78 | ||
79 | cat >expect <<\EOF | |
80 | Repo Guy (1): | |
81 | initial | |
82 | ||
83 | nick1 (1): | |
84 | second | |
85 | ||
86 | EOF | |
87 | ||
88 | test_expect_success 'mailmap.file non-existant' ' | |
89 | rm internal_mailmap/.mailmap && | |
90 | rmdir internal_mailmap && | |
91 | git shortlog HEAD >actual && | |
92 | test_cmp expect actual | |
93 | ' | |
94 | ||
95 | cat >expect <<\EOF | |
96 | A U Thor (1): | |
97 | initial | |
98 | ||
99 | nick1 (1): | |
100 | second | |
101 | ||
102 | EOF | |
103 | test_expect_success 'No mailmap files, but configured' ' | |
104 | rm .mailmap && | |
105 | git shortlog HEAD >actual && | |
106 | test_cmp expect actual | |
107 | ' | |
108 | ||
d20d654f MSO |
109 | # Extended mailmap configurations should give us the following output for shortlog |
110 | cat >expect <<\EOF | |
111 | A U Thor <author@example.com> (1): | |
112 | initial | |
113 | ||
114 | CTO <cto@company.xx> (1): | |
115 | seventh | |
116 | ||
117 | Other Author <other@author.xx> (2): | |
118 | third | |
119 | fourth | |
120 | ||
121 | Santa Claus <santa.claus@northpole.xx> (2): | |
122 | fifth | |
123 | sixth | |
124 | ||
125 | Some Dude <some@dude.xx> (1): | |
126 | second | |
127 | ||
128 | EOF | |
129 | ||
130 | test_expect_success 'Shortlog output (complex mapping)' ' | |
131 | echo three >>one && | |
132 | git add one && | |
133 | test_tick && | |
134 | git commit --author "nick2 <bugs@company.xx>" -m third && | |
135 | ||
136 | echo four >>one && | |
137 | git add one && | |
138 | test_tick && | |
139 | git commit --author "nick2 <nick2@company.xx>" -m fourth && | |
140 | ||
141 | echo five >>one && | |
142 | git add one && | |
143 | test_tick && | |
144 | git commit --author "santa <me@company.xx>" -m fifth && | |
145 | ||
146 | echo six >>one && | |
147 | git add one && | |
148 | test_tick && | |
149 | git commit --author "claus <me@company.xx>" -m sixth && | |
150 | ||
151 | echo seven >>one && | |
152 | git add one && | |
153 | test_tick && | |
154 | git commit --author "CTO <cto@coompany.xx>" -m seventh && | |
155 | ||
156 | mkdir internal_mailmap && | |
157 | echo "Committed <committer@example.com>" > internal_mailmap/.mailmap && | |
158 | echo "<cto@company.xx> <cto@coompany.xx>" >> internal_mailmap/.mailmap && | |
159 | echo "Some Dude <some@dude.xx> nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap && | |
160 | echo "Other Author <other@author.xx> nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap && | |
161 | echo "Other Author <other@author.xx> <nick2@company.xx>" >> internal_mailmap/.mailmap && | |
162 | echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap && | |
163 | echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap && | |
164 | ||
165 | git shortlog -e HEAD >actual && | |
166 | test_cmp expect actual | |
167 | ||
168 | ' | |
169 | ||
170 | # git log with --pretty format which uses the name and email mailmap placemarkers | |
171 | cat >expect <<\EOF | |
172 | Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx> | |
173 | Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> | |
174 | ||
175 | Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx> | |
176 | Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> | |
177 | ||
178 | Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx> | |
179 | Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> | |
180 | ||
181 | Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx> | |
182 | Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> | |
183 | ||
184 | Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx> | |
185 | Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> | |
186 | ||
187 | Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx> | |
188 | Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> | |
189 | ||
190 | Author A U Thor <author@example.com> maps to A U Thor <author@example.com> | |
191 | Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com> | |
192 | EOF | |
193 | ||
194 | test_expect_success 'Log output (complex mapping)' ' | |
195 | git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual && | |
196 | test_cmp expect actual | |
197 | ' | |
198 | ||
199 | # git blame | |
200 | cat >expect <<\EOF | |
201 | ^3a2fdcb (A U Thor 2005-04-07 15:13:13 -0700 1) one | |
202 | 7de6f99b (Some Dude 2005-04-07 15:13:13 -0700 2) two | |
203 | 5815879d (Other Author 2005-04-07 15:14:13 -0700 3) three | |
204 | ff859d96 (Other Author 2005-04-07 15:15:13 -0700 4) four | |
205 | 5ab6d4fa (Santa Claus 2005-04-07 15:16:13 -0700 5) five | |
206 | 38a42d8b (Santa Claus 2005-04-07 15:17:13 -0700 6) six | |
207 | 8ddc0386 (CTO 2005-04-07 15:18:13 -0700 7) seven | |
208 | EOF | |
209 | ||
210 | test_expect_success 'Blame output (complex mapping)' ' | |
211 | git blame one >actual && | |
212 | test_cmp expect actual | |
213 | ' | |
214 | ||
d551a488 | 215 | test_done |