#!/bin/sh # Checks link-commits.lua, the shipped commit-filter, whose configuration as # shipped links bare object names to ./?id= and leaves issue marks like #123 # as text until a tracker is set up. The unit checks cover the matching rules # under every suitable standalone Lua, and a commit whose message carries one # of each is then rendered through cgit itself. test_description='Check the shipped link-commits 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-commits.lua" "$EXTENSIONS_DIRECTORY/link-commits.lua" ' done test_expect_success 'create a repository whose commit message holds matches' ' test_create_repo repos/linky && ( cd repos/linky && echo content >file && git add file && git commit -m "fix #123 near deadbeefcafe1234" ) ' test_expect_success 'point cgit at it through the commit filter' ' cat >cgitrc <<-EOF virtual-root=/ cache-size=0 repo.url=linky repo.path=$PWD/repos/linky/.git repo.commit-filter=lua:$EXTENSIONS_DIRECTORY/link-commits.lua EOF ' test_expect_success CGIT_LUA 'the issue mark stays text on the commit page' ' cgit_ok_url "linky/commit/" >tmp && test_grep "fix #123 near" tmp && test_grep ! "bugs.example.com" tmp ' test_expect_success CGIT_LUA 'the object name links to its own page' ' cgit_ok_url "linky/commit/" >tmp && test_grep "id=deadbeefcafe1234.>deadbeefcafe1234" tmp ' test_done