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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
test_description='Check content on log page'
. ./setup.sh
test_expect_success 'generate foo/log' 'cgit_url "foo/log" >tmp'
test_expect_success 'find commit 1' 'grep "commit 1" tmp'
test_expect_success 'find commit 5' 'grep "commit 5" tmp'
test_expect_success 'generate bar/log' 'cgit_url "bar/log" >tmp'
test_expect_success 'find commit 1' 'grep ">commit 1<" tmp'
test_expect_success 'find commit 50' 'grep "commit 50" tmp'
test_expect_success 'a detached head stays selected in the switcher' '
sha=$(git -C repos/foo rev-parse master~1) &&
cgit_url "foo/log&h=$sha" >tmp &&
grep "option value=.$sha. selected" tmp
'
test_expect_success 'a tag head stays selected in the switcher' '
git -C repos/foo tag t-switch master~1 &&
cgit_url "foo/log&h=t-switch" >tmp &&
grep "option value=.t-switch. selected>t-switch (detached)" tmp &&
git -C repos/foo tag -d t-switch
'
test_expect_success 'a branch head keeps its plain option' '
cgit_url "foo/log&h=master" >tmp &&
grep "option value=.master. selected>master<" tmp &&
! grep "detached" tmp
'
test_expect_success 'generate "with%20space/log?qt=grep&q=commit+1"' '
cgit_url "with+space/log&qt=grep&q=commit+1" >tmp
'
test_expect_success 'find commit 1' 'grep ">commit 1<" tmp'
test_expect_success 'find link with %20 in path' 'grep "/with%20space/log/?qt=grep" tmp'
test_expect_success 'find link with + in arg' 'grep "/log/?qt=grep&q=commit+1" tmp'
test_expect_success 'no links with space in path' '! grep "href=./with space/" tmp'
test_expect_success 'no links with space in arg' '! grep "q=commit 1" tmp'
test_expect_success 'commit 2 is not visible' '! grep "commit 2" tmp'
test_expect_success 'set up a renamed file to follow' '
test_create_repo repos/fol &&
(
cd repos/fol &&
echo 1 >a.txt &&
git add a.txt &&
git commit -m "create a" &&
for i in 2 3 4
do
echo $i >>a.txt &&
git commit -am "edit a $i" || return 1
done &&
git mv a.txt b.txt &&
git commit -m "rename to b" &&
for i in 6 7 8
do
echo $i >>b.txt &&
git commit -am "edit b $i" || return 1
done
) &&
{
echo "virtual-root=/" &&
echo "cache-size=0" &&
echo "enable-follow-links=1" &&
echo "max-commit-count=3" &&
echo "repo.url=fol" &&
echo "repo.path=$PWD/repos/fol/.git"
} >folrc
'
test_expect_success 'a followed log reaches the root commit' '
CGIT_CONFIG="$PWD/folrc" QUERY_STRING="url=fol/log/b.txt&follow=1&ofs=6" cgit >tmp &&
grep ">edit a 2<" tmp &&
grep ">create a<" tmp
'
test_expect_success 'the pager of a followed log keeps the name followed' '
CGIT_CONFIG="$PWD/folrc" QUERY_STRING="url=fol/log/b.txt&follow=1&ofs=3" cgit >tmp &&
grep ">edit a 3<" tmp &&
grep "href=./fol/log/b.txt?follow=1.>\[prev\]" tmp &&
grep "href=./fol/log/b.txt?ofs=6&follow=1.>\[next\]" tmp
'
test_expect_success 'a cut subject keeps whole characters' '
git -C repos/foo commit --allow-empty -m "日本語の説明文です日本語の説明文です" &&
{
echo "max-message-length=20" &&
sed "s/^cache-size=.*/cache-size=0/" cgitrc
} >subjectrc &&
CGIT_CONFIG="$PWD/subjectrc" QUERY_STRING="url=foo/log/" cgit >tmp &&
grep ">日本語の説\.\.\.</a>" tmp
'
test_expect_success 'the log draws the commit graph when enabled' '
{
echo "enable-commit-graph=1" &&
sed "s/^cache-size=.*/cache-size=0/" cgitrc
} >graphrc &&
CGIT_CONFIG="$PWD/graphrc" QUERY_STRING="url=foo/log/" cgit >tmp &&
grep "class=.commitgraph." tmp &&
grep "<th scope=.col. aria-label=.Graph.></th>" tmp
'
test_expect_success 'a followed log heads its age column with the graph on' '
{
echo "enable-commit-graph=1" &&
cat folrc
} >folgraphrc &&
CGIT_CONFIG="$PWD/folgraphrc" QUERY_STRING="url=fol/log/b.txt&follow=1" cgit >tmp &&
grep "<th class=.left. scope=.col.>Age</th><th class=.left. scope=.col.>Commit message" tmp &&
! grep "aria-label=.Graph." tmp
'
test_expect_success 'a search for brackets matches them literally' '
git -C repos/foo commit --allow-empty -m "fix [brackets] in docs" &&
cgit_url "foo/log&qt=grep&q=%5Bbrackets" >tmp &&
grep "^Status: 200" tmp &&
grep "fix \\[brackets\\] in docs" tmp
'
test_expect_success 'a walk that cannot start answers one error page' '
git clone -q repos/foo gap &&
old=$(git -C gap rev-parse HEAD~4) &&
parent=$(git -C gap rev-parse HEAD~2) &&
rm gap/.git/objects/$(echo $parent | cut -c1-2)/$(echo $parent | cut -c3-) &&
{
echo "virtual-root=/" &&
echo "cache-size=0" &&
echo "repo.url=gap" &&
echo "repo.path=$PWD/gap/.git"
} >gaprc &&
CGIT_CONFIG="$PWD/gaprc" QUERY_STRING="url=gap/log/&qt=range&q=$old..master" cgit >tmp 2>err &&
test $(grep -c "^Status:" tmp) = 1 &&
grep "^Status: 500" tmp &&
grep "Unable to read the history" tmp
'
test_done
|