t / t4203-mailmap.shon commit SubmittingPatches: remove overlong checklist (7d5bf87)
   1#!/bin/sh
   2
   3test_description='.mailmap configurations'
   4
   5. ./test-lib.sh
   6
   7fuzz_blame () {
   8        sed "
   9                s/$_x05[0-9a-f][0-9a-f][0-9a-f]/OBJID/g
  10                s/$_x05[0-9a-f][0-9a-f]/OBJI/g
  11                s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
  12        " "$@"
  13}
  14
  15test_expect_success setup '
  16        echo one >one &&
  17        git add one &&
  18        test_tick &&
  19        git commit -m initial &&
  20        echo two >>one &&
  21        git add one &&
  22        test_tick &&
  23        git commit --author "nick1 <bugs@company.xx>" -m second
  24'
  25
  26cat >expect <<\EOF
  27A U Thor (1):
  28      initial
  29
  30nick1 (1):
  31      second
  32
  33EOF
  34
  35test_expect_success 'No mailmap' '
  36        git shortlog HEAD >actual &&
  37        test_cmp expect actual
  38'
  39
  40cat >expect <<\EOF
  41Repo Guy (1):
  42      initial
  43
  44nick1 (1):
  45      second
  46
  47EOF
  48
  49test_expect_success 'default .mailmap' '
  50        echo "Repo Guy <author@example.com>" > .mailmap &&
  51        git shortlog HEAD >actual &&
  52        test_cmp expect actual
  53'
  54
  55# Using a mailmap file in a subdirectory of the repo here, but
  56# could just as well have been a file outside of the repository
  57cat >expect <<\EOF
  58Internal Guy (1):
  59      second
  60
  61Repo Guy (1):
  62      initial
  63
  64EOF
  65test_expect_success 'mailmap.file set' '
  66        mkdir -p internal_mailmap &&
  67        echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap &&
  68        git config mailmap.file internal_mailmap/.mailmap &&
  69        git shortlog HEAD >actual &&
  70        test_cmp expect actual
  71'
  72
  73cat >expect <<\EOF
  74External Guy (1):
  75      initial
  76
  77Internal Guy (1):
  78      second
  79
  80EOF
  81test_expect_success 'mailmap.file override' '
  82        echo "External Guy <author@example.com>" >> internal_mailmap/.mailmap &&
  83        git config mailmap.file internal_mailmap/.mailmap &&
  84        git shortlog HEAD >actual &&
  85        test_cmp expect actual
  86'
  87
  88cat >expect <<\EOF
  89Repo Guy (1):
  90      initial
  91
  92nick1 (1):
  93      second
  94
  95EOF
  96
  97test_expect_success 'mailmap.file non-existent' '
  98        rm internal_mailmap/.mailmap &&
  99        rmdir internal_mailmap &&
 100        git shortlog HEAD >actual &&
 101        test_cmp expect actual
 102'
 103
 104cat >expect <<\EOF
 105Internal Guy (1):
 106      second
 107
 108Repo Guy (1):
 109      initial
 110
 111EOF
 112
 113test_expect_success 'name entry after email entry' '
 114        mkdir -p internal_mailmap &&
 115        echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
 116        echo "Internal Guy <bugs@company.xx>" >>internal_mailmap/.mailmap &&
 117        git shortlog HEAD >actual &&
 118        test_cmp expect actual
 119'
 120
 121cat >expect <<\EOF
 122Internal Guy (1):
 123      second
 124
 125Repo Guy (1):
 126      initial
 127
 128EOF
 129
 130test_expect_success 'name entry after email entry, case-insensitive' '
 131        mkdir -p internal_mailmap &&
 132        echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
 133        echo "Internal Guy <BUGS@Company.xx>" >>internal_mailmap/.mailmap &&
 134        git shortlog HEAD >actual &&
 135        test_cmp expect actual
 136'
 137
 138cat >expect <<\EOF
 139A U Thor (1):
 140      initial
 141
 142nick1 (1):
 143      second
 144
 145EOF
 146test_expect_success 'No mailmap files, but configured' '
 147        rm -f .mailmap internal_mailmap/.mailmap &&
 148        git shortlog HEAD >actual &&
 149        test_cmp expect actual
 150'
 151
 152# Extended mailmap configurations should give us the following output for shortlog
 153cat >expect <<\EOF
 154A U Thor <author@example.com> (1):
 155      initial
 156
 157CTO <cto@company.xx> (1):
 158      seventh
 159
 160Other Author <other@author.xx> (2):
 161      third
 162      fourth
 163
 164Santa Claus <santa.claus@northpole.xx> (2):
 165      fifth
 166      sixth
 167
 168Some Dude <some@dude.xx> (1):
 169      second
 170
 171EOF
 172
 173test_expect_success 'Shortlog output (complex mapping)' '
 174        echo three >>one &&
 175        git add one &&
 176        test_tick &&
 177        git commit --author "nick2 <bugs@company.xx>" -m third &&
 178
 179        echo four >>one &&
 180        git add one &&
 181        test_tick &&
 182        git commit --author "nick2 <nick2@company.xx>" -m fourth &&
 183
 184        echo five >>one &&
 185        git add one &&
 186        test_tick &&
 187        git commit --author "santa <me@company.xx>" -m fifth &&
 188
 189        echo six >>one &&
 190        git add one &&
 191        test_tick &&
 192        git commit --author "claus <me@company.xx>" -m sixth &&
 193
 194        echo seven >>one &&
 195        git add one &&
 196        test_tick &&
 197        git commit --author "CTO <cto@coompany.xx>" -m seventh &&
 198
 199        mkdir -p internal_mailmap &&
 200        echo "Committed <committer@example.com>" > internal_mailmap/.mailmap &&
 201        echo "<cto@company.xx>                       <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
 202        echo "Some Dude <some@dude.xx>         nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
 203        echo "Other Author <other@author.xx>   nick2 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
 204        echo "Other Author <other@author.xx>         <nick2@company.xx>" >> internal_mailmap/.mailmap &&
 205        echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
 206        echo "Santa Claus <santa.claus@northpole.xx> <me@company.xx>" >> internal_mailmap/.mailmap &&
 207
 208        git shortlog -e HEAD >actual &&
 209        test_cmp expect actual
 210
 211'
 212
 213# git log with --pretty format which uses the name and email mailmap placemarkers
 214cat >expect <<\EOF
 215Author CTO <cto@coompany.xx> maps to CTO <cto@company.xx>
 216Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 217
 218Author claus <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
 219Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 220
 221Author santa <me@company.xx> maps to Santa Claus <santa.claus@northpole.xx>
 222Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 223
 224Author nick2 <nick2@company.xx> maps to Other Author <other@author.xx>
 225Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 226
 227Author nick2 <bugs@company.xx> maps to Other Author <other@author.xx>
 228Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 229
 230Author nick1 <bugs@company.xx> maps to Some Dude <some@dude.xx>
 231Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 232
 233Author A U Thor <author@example.com> maps to A U Thor <author@example.com>
 234Committer C O Mitter <committer@example.com> maps to Committed <committer@example.com>
 235EOF
 236
 237test_expect_success 'Log output (complex mapping)' '
 238        git log --pretty=format:"Author %an <%ae> maps to %aN <%aE>%nCommitter %cn <%ce> maps to %cN <%cE>%n" >actual &&
 239        test_cmp expect actual
 240'
 241
 242# git blame
 243cat >expect <<\EOF
 244^OBJI (A U Thor     DATE 1) one
 245OBJID (Some Dude    DATE 2) two
 246OBJID (Other Author DATE 3) three
 247OBJID (Other Author DATE 4) four
 248OBJID (Santa Claus  DATE 5) five
 249OBJID (Santa Claus  DATE 6) six
 250OBJID (CTO          DATE 7) seven
 251EOF
 252test_expect_success 'Blame output (complex mapping)' '
 253        git blame one >actual &&
 254        fuzz_blame actual >actual.fuzz &&
 255        test_cmp expect actual.fuzz
 256'
 257
 258test_done