Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Check the trailer values each path takes
The ident said to follow the mailmap had no entry in it, and the
commit filter that takes a value when no trailer filter is set had no
test, nor did brackets without an address, a message of nothing but a
block and the repository flag turning the table on. One test appended
to the shared config, and seven read a page an earlier test fetched.
| -rwxr-xr-x | tests/t0206-trailers.sh | 90 |
1 file changed, 62 insertions, 28 deletions
diff --git a/tests/t0206-trailers.sh b/tests/t0206-trailers.sh index 70f10bd..5a8fe97 100755 --- a/tests/t0206-trailers.sh +++ b/tests/t0206-trailers.sh @@ -3,9 +3,10 @@ # 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. +# one receives show in the page, then through the commit filter alone, then +# with the flag off globally and off for the one repository. The repository +# carries a mailmap, so the idents are checked to follow it. Commits with no +# block, or nothing but one, are checked as well. test_description='Check the commit trailers table' CGIT_TEST_NO_CREATE_REPOS=YesPlease @@ -16,9 +17,17 @@ test_expect_success 'create a repository with a trailer-shaped message' ' ( cd repos/trailers && echo content >file && - echo "Mapped Name <mapped@example.com> <author@example.com>" >.mailmap && + { + echo "Mapped Name <mapped@example.com> <author@example.com>" && + echo "Some Body <body@example.com> <some@example.com>" + } >.mailmap && git add file .mailmap && git commit -m "plain commit" && + git commit --allow-empty -F - <<-\EOF && + Only trailers + + Signed-off-by: A U Thor <author@example.com> + EOF echo more >>file && git add file && git commit -F - <<-\EOF @@ -33,80 +42,105 @@ test_expect_success 'create a repository with a trailer-shaped message' ' Reported-by: (cherry picked from commit deadbeefcafe1234) Link: https://example.com/?a=1&b=2 + Cc: list <not-an-address> 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 + ) && + cgitrc_repo trailersrc trailers enable-commit-trailers=1 \ + "repo.trailer-filter=exec:$FILTER_DIRECTORY/dump.sh" \ + "repo.email-filter=exec:$FILTER_DIRECTORY/dump.sh" ' test_expect_success 'the body ends where the block begins' ' + cgit_ok trailersrc "url=trailers/commit/" >tmp && grep "<div class=.commit-msg.>The body keeps its colon: it is not a trailer.</div>" tmp ' test_expect_success 'a value reaches the trailer filter with its key and page' ' - grep "<tr><th scope=.row.>Fixes</th><td>Fixes commit 1234567 (.PLAIN COMMIT.)</td></tr>" tmp + cgit_ok trailersrc "url=trailers/commit/" >tmp && + grep "<tr><th scope=.row.>Fixes</th><td>Fixes commit 1234567 (\"PLAIN COMMIT\")</td></tr>" tmp ' test_expect_success 'a run of one key, whatever its case, collapses into one row' ' + cgit_ok trailersrc "url=trailers/commit/" >tmp && grep "<tr><th scope=.row.>Signed-off-by</th><td><mapped@example.com> commit MAPPED NAME <MAPPED@EXAMPLE.COM><br><committer@example.com> commit C O MITTER <COMMITTER@EXAMPLE.COM></td></tr>" tmp ' test_expect_success 'an ident follows the mailmap and keeps what trails the address' ' - grep "<tr><th scope=.row.>Acked-by</th><td><some@example.com> commit SOME ONE <SOME@EXAMPLE.COM> (maintainer)</td></tr>" tmp + cgit_ok trailersrc "url=trailers/commit/" >tmp && + grep "<tr><th scope=.row.>Acked-by</th><td><body@example.com> commit SOME BODY <BODY@EXAMPLE.COM> (maintainer)</td></tr>" tmp +' + +# Brackets with no address in them make no ident, so the value goes to the +# trailer filter like any other text. +test_expect_success 'a value with brackets but no address is no ident' ' + cgit_ok trailersrc "url=trailers/commit/" >tmp && + grep "<tr><th scope=.row.>Cc</th><td>Cc commit LIST <NOT-AN-ADDRESS></td></tr>" tmp ' test_expect_success 'a key with no value is printed as written' ' + cgit_ok trailersrc "url=trailers/commit/" >tmp && grep "<tr><td colspan=.2.>Reported-by:</td></tr>" tmp ' test_expect_success 'a line git could not split gets a row of its own' ' + cgit_ok trailersrc "url=trailers/commit/" >tmp && grep "<tr><td colspan=.2.>(cherry picked from commit deadbeefcafe1234)</td></tr>" tmp ' test_expect_success 'the escaped value is what the filter sees' ' + cgit_ok trailersrc "url=trailers/commit/" >tmp && grep "<tr><th scope=.row.>Link</th><td>Link commit HTTPS://EXAMPLE.COM/?A=1&B=2</td></tr>" tmp ' +# With no trailer filter, a value goes through the commit filter, which is +# handed no key and no page, while an ident still takes the email path. +test_expect_success 'without a trailer filter the commit filter takes the values' ' + cgitrc_repo commitfilterrc trailers enable-commit-trailers=1 \ + "repo.commit-filter=exec:$FILTER_DIRECTORY/dump.sh" && + cgit_ok commitfilterrc "url=trailers/commit/" >tmp && + grep "<tr><th scope=.row.>Fixes</th><td>1234567 (\"PLAIN COMMIT\")</td></tr>" tmp && + grep "<tr><th scope=.row.>Acked-by</th><td>Some Body <body@example.com> (maintainer)</td></tr>" tmp +' + # The dump filter is handed the address whatever the setting, so the page is # drawn without it here. test_expect_success 'enable-plain-email=0 leaves the addresses off the idents' ' cgitrc_repo plainrc trailers enable-commit-trailers=1 enable-plain-email=0 && cgit_ok plainrc "url=trailers/commit/" >tmp && grep "<tr><th scope=.row.>Signed-off-by</th><td>Mapped Name<br>C O Mitter</td></tr>" tmp && - grep "<tr><th scope=.row.>Acked-by</th><td>Some One (maintainer)</td></tr>" tmp && + grep "<tr><th scope=.row.>Acked-by</th><td>Some Body (maintainer)</td></tr>" tmp && ! grep "@example.com" 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 && + plain=$(git -C repos/trailers rev-parse HEAD~2) && + cgit_ok trailersrc "url=trailers/commit/&id=$plain" >tmp && grep "<div class=.commit-msg.></div>" tmp && ! grep "commit-trailers" tmp ' +test_expect_success 'a message of nothing but a block is all table' ' + only=$(git -C repos/trailers rev-parse HEAD~1) && + cgit_ok trailersrc "url=trailers/commit/&id=$only" >tmp && + grep "<div class=.commit-msg.></div>" tmp && + grep "<tr><th scope=.row.>Signed-off-by</th><td><mapped@example.com> commit MAPPED NAME <MAPPED@EXAMPLE.COM></td></tr>" 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_rc cgitrc-off "url=trailers/commit/" >tmp && + cgitrc_repo offrc trailers && + cgit_ok offrc "url=trailers/commit/" >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 && + cgitrc_repo repooffrc trailers enable-commit-trailers=1 repo.enable-commit-trailers=0 && + cgit_ok repooffrc "url=trailers/commit/" >tmp && ! grep "commit-trailers" tmp && - grep "Signed-off-by: A U Thor" tmp + grep "Signed-off-by: A U Thor" tmp && + cgitrc_repo repoonrc trailers enable-commit-trailers=0 repo.enable-commit-trailers=1 && + cgit_ok repoonrc "url=trailers/commit/" >tmp && + grep "<table class=.commit-trailers.>" tmp ' test_done |
