#!/bin/sh
# The tag page. An annotated tag gets a table of its name, date, tagger, the
# object it points at under its full id, and the downloads, and its message
# follows with no blank line between subject and body. A lightweight tag gets
# the shorter table. The tags the first test makes serve the rest.
test_description='Check content on tag page'
. ./setup.sh
test_expect_success 'create an annotated and a lightweight tag' '
(
cd repos/foo &&
git tag -a -m "Annotated tag
Release notes over
two lines." v1.0 &&
git tag light
)
'
test_expect_success 'find the name, date and tagger rows' '
tag=$(git -C repos/foo rev-parse v1.0) &&
cgit_ok_url "foo/tag/&h=v1.0" >tmp &&
test_grep "
tag name
v1.0 ($tag)
" tmp &&
test_grep "
tag date
" tmp &&
test_grep "
tagged by
C O Mitter <committer@example.com>
" tmp
'
test_expect_success 'the object row names the full commit id' '
commit=$(git -C repos/foo rev-parse v1.0^{commit}) &&
cgit_ok_url "foo/tag/&h=v1.0" >tmp &&
grep "
" tmp
'
test_expect_success 'a name that is no tag is a 404' '
cgit_url "foo/tag/&id=no-such-tag" >tmp &&
test_grep "^Status: 404" tmp &&
test_grep "
Bad tag reference: no-such-tag
" tmp
'
# No ref names the inner tag of a tag of a tag, so the outer tag's page links
# it by its id, which the tag page has to answer.
test_expect_success 'a tag of a tag links the inner tag' '
git -C repos/foo tag -a -m inner inner-tag HEAD &&
git -C repos/foo -c advice.nestedTag=false tag -a -m outer outer-tag inner-tag &&
inner=$(git -C repos/foo rev-parse inner-tag) &&
commit=$(git -C repos/foo rev-parse inner-tag^{commit}) &&
cgit_ok_url "foo/tag/&h=outer-tag" >tmp &&
test_grep "
" tmp &&
test_grep "commit $commit" tmp
'
# A snapshot is cut from a commit, so a tag of a tree or a blob offers none.
test_expect_success 'a tag of anything but a commit offers no download' '
git -C repos/foo tag -a -m "a tree" tree-tag HEAD^{tree} &&
git -C repos/foo tag blob-tag HEAD:file-1 &&
cgit_ok_url "foo/tag/&h=tree-tag" >tmp &&
grep "tagged object" tmp &&
test_grep ! ">download<" tmp &&
cgit_ok_url "foo/tag/&h=blob-tag" >tmp &&
grep "tagged object" tmp &&
test_grep ! ">download<" tmp
'
# git reads the signature off the end of a tag's message, so a block shaped
# like one is enough, with nothing to verify.
test_expect_success 'a signed tag shows its signature in the message' '
(
cd repos/foo &&
{
echo "object $(git rev-parse HEAD)" &&
echo "type commit" &&
echo "tag signed" &&
echo "tagger C O Mitter 1700000000 +0000" &&
echo &&
echo "Signed release" &&
echo &&
echo "Notes." &&
echo &&
echo "-----BEGIN PGP SIGNATURE-----" &&
echo "iQEzBAABCAAdFiEE" &&
echo "-----END PGP SIGNATURE-----"
} >signed-tag &&
git update-ref refs/tags/signed $(git mktag tmp &&
tr -d "\n" flat &&
grep "
" flat
'
# A tag carries no encoding header, so its text is taken as UTF-8, and a byte
# that is not has a question mark put in its place on a page declared UTF-8.
test_expect_success 'a tag has its stray bytes replaced' '
(
cd repos/foo &&
{
echo "object $(git rev-parse HEAD)" &&
echo "type commit" &&
echo "tag latin" &&
printf "tagger C\\351 Mitter 1700000000 +0000\\n" &&
echo &&
printf "caf\\351 release\\n"
} >latin-tag &&
git update-ref refs/tags/latin $(git hash-object -t tag -w --literally latin-tag)
) &&
cgit_ok_url "foo/tag/&h=latin" >tmp &&
test_grep "
C? Mitter <committer@example.com>
" tmp &&
test_grep "
caf? release
" tmp &&
test_grep ! "$(printf "\\351")" tmp
'
test_expect_success 'a tag page names the tag in its title' '
cgit_ok_url "foo/tag/&h=v1.0" >tmp &&
grep "v1.0 - foo - Git repository browser" tmp
'
test_done