Skip to content

Commit 45e206f

Browse files
praritgitster
authored andcommitted
t4203: use test-lib.sh definitions
Use name and email definitions from test-lib.sh. Signed-off-by: Prarit Bhargava <prarit@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 2ae4944 commit 45e206f

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

t/t4203-mailmap.sh

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ fuzz_blame () {
1313
}
1414

1515
test_expect_success setup '
16-
cat >contacts <<-\EOF &&
17-
A U Thor <author@example.com>
16+
cat >contacts <<- EOF &&
17+
$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
1818
nick1 <bugs@company.xx>
1919
EOF
2020
@@ -33,19 +33,19 @@ test_expect_success 'check-mailmap no arguments' '
3333
'
3434

3535
test_expect_success 'check-mailmap arguments' '
36-
cat >expect <<-\EOF &&
37-
A U Thor <author@example.com>
36+
cat >expect <<- EOF &&
37+
$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
3838
nick1 <bugs@company.xx>
3939
EOF
4040
git check-mailmap \
41-
"A U Thor <author@example.com>" \
41+
"$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>" \
4242
"nick1 <bugs@company.xx>" >actual &&
4343
test_cmp expect actual
4444
'
4545

4646
test_expect_success 'check-mailmap --stdin' '
47-
cat >expect <<-\EOF &&
48-
A U Thor <author@example.com>
47+
cat >expect <<- EOF &&
48+
$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
4949
nick1 <bugs@company.xx>
5050
EOF
5151
git check-mailmap --stdin <contacts >actual &&
@@ -66,8 +66,8 @@ test_expect_success 'check-mailmap bogus contact' '
6666
test_must_fail git check-mailmap bogus
6767
'
6868

69-
cat >expect <<\EOF
70-
A U Thor (1):
69+
cat >expect << EOF
70+
$GIT_AUTHOR_NAME (1):
7171
initial
7272
7373
nick1 (1):
@@ -90,7 +90,7 @@ nick1 (1):
9090
EOF
9191

9292
test_expect_success 'default .mailmap' '
93-
echo "Repo Guy <author@example.com>" > .mailmap &&
93+
echo "Repo Guy <$GIT_AUTHOR_EMAIL>" > .mailmap &&
9494
git shortlog HEAD >actual &&
9595
test_cmp expect actual
9696
'
@@ -122,7 +122,7 @@ Internal Guy (1):
122122
123123
EOF
124124
test_expect_success 'mailmap.file override' '
125-
echo "External Guy <author@example.com>" >> internal_mailmap/.mailmap &&
125+
echo "External Guy <$GIT_AUTHOR_EMAIL>" >> internal_mailmap/.mailmap &&
126126
git config mailmap.file internal_mailmap/.mailmap &&
127127
git shortlog HEAD >actual &&
128128
test_cmp expect actual
@@ -178,8 +178,8 @@ test_expect_success 'name entry after email entry, case-insensitive' '
178178
test_cmp expect actual
179179
'
180180

181-
cat >expect <<\EOF
182-
A U Thor (1):
181+
cat >expect << EOF
182+
$GIT_AUTHOR_NAME (1):
183183
initial
184184
185185
nick1 (1):
@@ -195,18 +195,18 @@ test_expect_success 'No mailmap files, but configured' '
195195
test_expect_success 'setup mailmap blob tests' '
196196
git checkout -b map &&
197197
test_when_finished "git checkout master" &&
198-
cat >just-bugs <<-\EOF &&
198+
cat >just-bugs <<- EOF &&
199199
Blob Guy <bugs@company.xx>
200200
EOF
201-
cat >both <<-\EOF &&
202-
Blob Guy <author@example.com>
201+
cat >both <<- EOF &&
202+
Blob Guy <$GIT_AUTHOR_EMAIL>
203203
Blob Guy <bugs@company.xx>
204204
EOF
205-
printf "Tricky Guy <author@example.com>" >no-newline &&
205+
printf "Tricky Guy <$GIT_AUTHOR_EMAIL>" >no-newline &&
206206
git add just-bugs both no-newline &&
207207
git commit -m "my mailmaps" &&
208-
echo "Repo Guy <author@example.com>" >.mailmap &&
209-
echo "Internal Guy <author@example.com>" >internal.map
208+
echo "Repo Guy <$GIT_AUTHOR_EMAIL>" >.mailmap &&
209+
echo "Internal Guy <$GIT_AUTHOR_EMAIL>" >internal.map
210210
'
211211

212212
test_expect_success 'mailmap.blob set' '
@@ -266,12 +266,12 @@ test_expect_success 'mailmap.blob defaults to off in non-bare repo' '
266266
git init non-bare &&
267267
(
268268
cd non-bare &&
269-
test_commit one .mailmap "Fake Name <author@example.com>" &&
269+
test_commit one .mailmap "Fake Name <$GIT_AUTHOR_EMAIL>" &&
270270
echo " 1 Fake Name" >expect &&
271271
git shortlog -ns HEAD >actual &&
272272
test_cmp expect actual &&
273273
rm .mailmap &&
274-
echo " 1 A U Thor" >expect &&
274+
echo " 1 $GIT_AUTHOR_NAME" >expect &&
275275
git shortlog -ns HEAD >actual &&
276276
test_cmp expect actual
277277
)
@@ -305,26 +305,26 @@ test_expect_success 'cleanup after mailmap.blob tests' '
305305
'
306306

307307
test_expect_success 'single-character name' '
308-
echo " 1 A <author@example.com>" >expect &&
308+
echo " 1 A <$GIT_AUTHOR_EMAIL>" >expect &&
309309
echo " 1 nick1 <bugs@company.xx>" >>expect &&
310-
echo "A <author@example.com>" >.mailmap &&
310+
echo "A <$GIT_AUTHOR_EMAIL>" >.mailmap &&
311311
test_when_finished "rm .mailmap" &&
312312
git shortlog -es HEAD >actual &&
313313
test_cmp expect actual
314314
'
315315

316316
test_expect_success 'preserve canonical email case' '
317-
echo " 1 A U Thor <AUTHOR@example.com>" >expect &&
317+
echo " 1 $GIT_AUTHOR_NAME <AUTHOR@example.com>" >expect &&
318318
echo " 1 nick1 <bugs@company.xx>" >>expect &&
319-
echo "<AUTHOR@example.com> <author@example.com>" >.mailmap &&
319+
echo "<AUTHOR@example.com> <$GIT_AUTHOR_EMAIL>" >.mailmap &&
320320
test_when_finished "rm .mailmap" &&
321321
git shortlog -es HEAD >actual &&
322322
test_cmp expect actual
323323
'
324324

325325
# Extended mailmap configurations should give us the following output for shortlog
326-
cat >expect <<\EOF
327-
A U Thor <author@example.com> (1):
326+
cat >expect << EOF
327+
$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> (1):
328328
initial
329329
330330
CTO <cto@company.xx> (1):
@@ -370,7 +370,7 @@ test_expect_success 'Shortlog output (complex mapping)' '
370370
git commit --author "CTO <cto@coompany.xx>" -m seventh &&
371371
372372
mkdir -p internal_mailmap &&
373-
echo "Committed <committer@example.com>" > internal_mailmap/.mailmap &&
373+
echo "Committed <$GIT_COMMITTER_EMAIL>" > internal_mailmap/.mailmap &&
374374
echo "<cto@company.xx> <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
375375
echo "Some Dude <some@dude.xx> nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
376376
echo "Other Author <other@author.xx> nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
@@ -384,57 +384,57 @@ test_expect_success 'Shortlog output (complex mapping)' '
384384
'
385385

386386
# git log with --pretty format which uses the name and email mailmap placemarkers
387-
cat >expect <<\EOF
387+
cat >expect << EOF
388388
Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>
389-
Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
389+
Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
390390
391391
Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
392-
Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
392+
Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
393393
394394
Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
395-
Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
395+
Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
396396
397397
Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>
398-
Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
398+
Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
399399
400400
Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>
401-
Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
401+
Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
402402
403403
Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx>
404-
Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
404+
Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
405405
406-
Author A U Thor <author@example.com> maps to A U Thor <author@example.com>
407-
Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
406+
Author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> maps to $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
407+
Committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> maps to Committed <$GIT_COMMITTER_EMAIL>
408408
EOF
409409

410410
test_expect_success 'Log output (complex mapping)' '
411411
git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
412412
test_cmp expect actual
413413
'
414414

415-
cat >expect <<\EOF
415+
cat >expect << EOF
416416
Author: CTO <cto@company.xx>
417417
Author: Santa Claus <santa.claus@northpole.xx>
418418
Author: Santa Claus <santa.claus@northpole.xx>
419419
Author: Other Author <other@author.xx>
420420
Author: Other Author <other@author.xx>
421421
Author: Some Dude <some@dude.xx>
422-
Author: A U Thor <author@example.com>
422+
Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
423423
EOF
424424

425425
test_expect_success 'Log output with --use-mailmap' '
426426
git log --use-mailmap | grep Author >actual &&
427427
test_cmp expect actual
428428
'
429429

430-
cat >expect <<\EOF
430+
cat >expect << EOF
431431
Author: CTO <cto@company.xx>
432432
Author: Santa Claus <santa.claus@northpole.xx>
433433
Author: Santa Claus <santa.claus@northpole.xx>
434434
Author: Other Author <other@author.xx>
435435
Author: Other Author <other@author.xx>
436436
Author: Some Dude <some@dude.xx>
437-
Author: A U Thor <author@example.com>
437+
Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
438438
EOF
439439

440440
test_expect_success 'Log output with log.mailmap' '
@@ -443,28 +443,28 @@ test_expect_success 'Log output with log.mailmap' '
443443
'
444444

445445
test_expect_success 'log.mailmap=false disables mailmap' '
446-
cat >expect <<-\EOF &&
446+
cat >expect <<- EOF &&
447447
Author: CTO <cto@coompany.xx>
448448
Author: claus <me@company.xx>
449449
Author: santa <me@company.xx>
450450
Author: nick2 <nick2@company.xx>
451451
Author: nick2 <bugs@company.xx>
452452
Author: nick1 <bugs@company.xx>
453-
Author: A U Thor <author@example.com>
453+
Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
454454
EOF
455455
git -c log.mailmap=False log | grep Author > actual &&
456456
test_cmp expect actual
457457
'
458458

459459
test_expect_success '--no-use-mailmap disables mailmap' '
460-
cat >expect <<-\EOF &&
460+
cat >expect <<- EOF &&
461461
Author: CTO <cto@coompany.xx>
462462
Author: claus <me@company.xx>
463463
Author: santa <me@company.xx>
464464
Author: nick2 <nick2@company.xx>
465465
Author: nick2 <bugs@company.xx>
466466
Author: nick1 <bugs@company.xx>
467-
Author: A U Thor <author@example.com>
467+
Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
468468
EOF
469469
git log --no-use-mailmap | grep Author > actual &&
470470
test_cmp expect actual
@@ -500,8 +500,8 @@ test_expect_success 'Only grep replaced author with --use-mailmap' '
500500
'
501501

502502
# git blame
503-
cat >expect <<\EOF
504-
^OBJI (A U Thor DATE 1) one
503+
cat >expect <<EOF
504+
^OBJI ($GIT_AUTHOR_NAME DATE 1) one
505505
OBJID (Some Dude DATE 2) two
506506
OBJID (Other Author DATE 3) three
507507
OBJID (Other Author DATE 4) four

0 commit comments

Comments
 (0)