#!/bin/sh # Checks link-trailers.lua, the shipped trailer-filter, whose configuration as # shipped links Fixes and Reverts object names to ./?id= and a bare URL to # itself, and leaves Closes and Bug marks as text until a tracker is set up. # The unit checks cover the rules under every suitable standalone Lua, and a # commit carrying one of each is then rendered through cgit itself. test_description='Check the shipped link-trailers extension' CGIT_TEST_NO_CREATE_REPOS=YesPlease . ./setup.sh . "$TEST_OUTPUT_DIRECTORY/extensions/lib.sh" for lua in ${interpreters:-lua} do test_expect_success STANDALONE_LUA "unit checks under $(lua_version "$lua")" ' "$lua" "$EXT_TEST_DIRECTORY/test-link-trailers.lua" "$EXTENSIONS_DIRECTORY/link-trailers.lua" ' done test_expect_success 'create a repository whose commit carries linkable trailers' ' test_create_repo repos/linky && ( cd repos/linky && echo content >file && git add file && git commit -F - <<-\EOF fix it Fixes: 1234567 ("earlier") Link: https://example.com/?a=1&b=2 Closes: #45 EOF ) ' test_expect_success 'point cgit at it through the trailer filter' ' cat >cgitrc <<-EOF virtual-root=/ cache-size=0 enable-commit-trailers=1 repo.url=linky repo.path=$PWD/repos/linky/.git repo.trailer-filter=lua:$EXTENSIONS_DIRECTORY/link-trailers.lua EOF ' test_expect_success CGIT_LUA 'the Fixes object name links to its commit page' ' cgit_ok_url "linky/commit/" >tmp && test_grep "Fixes1234567 (.earlier.)" tmp ' test_expect_success CGIT_LUA 'the bare URL links to itself' ' cgit_ok_url "linky/commit/" >tmp && test_grep "https://example.com/?a=1&b=2" tmp ' test_expect_success CGIT_LUA 'the Closes mark stays text' ' cgit_ok_url "linky/commit/" >tmp && test_grep "Closes#45" tmp ' test_done