#!/bin/sh # The trailer table on the commit page. A commit whose message ends in a # trailer block is rendered with enable-commit-trailers on, through the exec # dump filter as both trailer filter and email filter so the arguments each # one receives show in the page, then with the flag off globally and off for # the one repository. The repository carries a mailmap, so the sign-off idents # are checked to follow it. A commit with no block is checked to get no table. test_description='Check the commit trailers table' CGIT_TEST_NO_CREATE_REPOS=YesPlease . ./setup.sh test_expect_success 'create a repository with a trailer-shaped message' ' test_create_repo repos/trailers && ( cd repos/trailers && echo content >file && echo "Mapped Name " >.mailmap && git add file .mailmap && git commit -m "plain commit" && echo more >>file && git add file && git commit -F - <<-\EOF Fix the frobnicator The body keeps its colon: it is not a trailer. Fixes: 1234567 ("plain commit") Signed-off-by: A U Thor signed-off-by: C O Mitter Acked-by: Some One (maintainer) Reported-by: (cherry picked from commit deadbeefcafe1234) Link: https://example.com/?a=1&b=2 EOF ) ' test_expect_success 'point cgit at it with trailers on and the dump filters' ' cat >cgitrc <<-EOF && virtual-root=/ cache-size=0 enable-commit-trailers=1 repo.url=trailers repo.path=$PWD/repos/trailers/.git repo.trailer-filter=exec:$FILTER_DIRECTORY/dump.sh repo.email-filter=exec:$FILTER_DIRECTORY/dump.sh EOF cgit_url "trailers/commit/" >tmp ' test_expect_success 'the body ends where the block begins' ' grep "
The body keeps its colon: it is not a trailer.
" tmp ' test_expect_success 'a value reaches the trailer filter with its key and page' ' grep "FixesFixes commit 1234567 (.PLAIN COMMIT.)" tmp ' test_expect_success 'a run of one key, whatever its case, collapses into one row' ' grep "Signed-off-by commit MAPPED NAME <MAPPED@EXAMPLE.COM>
commit C O MITTER <COMMITTER@EXAMPLE.COM>" tmp ' test_expect_success 'an ident follows the mailmap and keeps what trails the address' ' grep "Acked-by commit SOME ONE <SOME@EXAMPLE.COM> (maintainer)" tmp ' test_expect_success 'a key with no value is printed as written' ' grep "Reported-by:" tmp ' test_expect_success 'a line git could not split gets a row of its own' ' grep "(cherry picked from commit deadbeefcafe1234)" tmp ' test_expect_success 'the escaped value is what the filter sees' ' grep "LinkLink commit HTTPS://EXAMPLE.COM/?A=1&B=2" tmp ' test_expect_success 'a message with no block gets no table' ' plain=$(git -C repos/trailers rev-parse HEAD~1) && cgit_url "trailers/commit/&id=$plain" >tmp && grep "
" tmp && ! grep "commit-trailers" tmp ' test_expect_success 'with the flag off the message stays whole' ' sed "s/^enable-commit-trailers=1/enable-commit-trailers=0/" cgitrc >cgitrc-off && CGIT_CONFIG="$PWD/cgitrc-off" QUERY_STRING="url=trailers/commit/" cgit >tmp && ! grep "commit-trailers" tmp && grep "Signed-off-by: A U Thor" tmp ' test_expect_success 'the repository flag overrides the global one' ' echo "repo.enable-commit-trailers=0" >>cgitrc && cgit_url "trailers/commit/" >tmp && ! grep "commit-trailers" tmp && grep "Signed-off-by: A U Thor" tmp ' test_done