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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
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 "<tr><th scope=.row.>tag name</th><td>v1.0 (<span class=.oid.>$tag</span>)</td></tr>" tmp &&
test_grep "<tr><th scope=.row.>tag date</th><td><time datetime=.2005-04-01T13:14:15+02:00.>2005-04-01 13:14:15 +0200</time></td></tr>" tmp &&
test_grep "<tr><th scope=.row.>tagged by</th><td>C O Mitter <committer@example.com></td></tr>" 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 "<tr><th scope=.row.>tagged object</th><td class=.oid.><a href=./foo/commit/?h=v1.0&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' '
cgit_ok_url "foo/tag/&h=v1.0" >tmp &&
test_grep "<div class=.commit-subject.>Annotated tag</div><div class=.commit-msg.>Release notes over$" tmp &&
test_grep "^two lines\.$" tmp
'
test_expect_success 'a lightweight tag gets the shorter table' '
cgit_ok_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 &&
test_grep ! "<th scope=.row.>tag date</th>" tmp &&
test_grep ! "<th scope=.row.>tagged by</th>" 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 "<div class=.error.>Bad tag reference: no-such-tag</div>" tmp
'
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 "<tr><th scope=.row.>tagged object</th><td class=.oid.><a href=./foo/tag/?h=outer-tag&id=$inner.>tag $inner</a></td></tr>" tmp &&
cgit_ok_url "foo/tag/&h=outer-tag&id=$inner" >tmp &&
test_grep "<tr><th scope=.row.>tag name</th><td>$inner (<span class=.oid.>$inner</span>)</td></tr>" tmp &&
test_grep "<a href=./foo/commit/?h=outer-tag&id=$commit.>commit $commit</a>" tmp
'
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
'
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 <committer@example.com> 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 <signed-tag)
) &&
cgit_ok_url "foo/tag/&h=signed" >tmp &&
tr -d "\n" <tmp >flat &&
grep "<div class=.commit-msg.>Notes.-----BEGIN PGP SIGNATURE-----iQEzBAABCAAdFiEE-----END PGP SIGNATURE-----</div>" flat
'
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 <committer@example.com> 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 "<td>C? Mitter <committer@example.com></td>" tmp &&
test_grep "<div class=.commit-subject.>caf? release</div>" 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 "<title>v1.0 - foo - Git repository browser</title>" tmp
'
test_done
|