blob: 2c9dc2598651f4d81a8101c9a3344e0b8b25ad7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/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.

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 'generate foo/tag/?h=v1.0' 'cgit_url "foo/tag/&h=v1.0" >tmp'

test_expect_success 'find the name, date and tagger rows' '
	grep "<tr><th scope=.row.>tag name</th><td>v1.0 (<span class=.oid.>[0-9a-f]*</span>)</td></tr>" tmp &&
	grep "<tr><th scope=.row.>tag date</th><td><time datetime=" tmp &&
	grep "<tr><th scope=.row.>tagged by</th><td>C O Mitter &lt;committer@example.com&gt;</td></tr>" tmp
'

test_expect_success 'the object row names the full commit id' '
	commit=$(git -C repos/foo rev-parse v1.0^{commit}) &&
	grep "<tr><th scope=.row.>tagged object</th><td class=.oid.><a href=./foo/commit/?h=v1.0&amp;id=$commit.>commit $commit</a></td></tr>" tmp &&
	grep "<tr><th scope=.row.>download</th><td class=.oid.>" tmp
'

test_expect_success 'the message follows with no blank line before the body' '
	tr -d "\n" <tmp >flat &&
	grep "<div class=.commit-subject.>Annotated tag</div><div class=.commit-msg.>Release notes overtwo lines.</div>" flat
'

test_expect_success 'a lightweight tag gets the shorter table' '
	cgit_url "foo/tag/&h=light" >tmp &&
	grep "<tr><th scope=.row.>tag name</th><td>light</td></tr>" tmp &&
	grep "<tr><th scope=.row.>tagged object</th><td class=.oid.><a" tmp &&
	! grep "<th scope=.row.>tagged by</th>" tmp
'

test_done