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
|
test_description='Check content on summary page'
. ./setup.sh
test_expect_success 'generate foo summary' 'cgit_url "foo" >tmp'
test_expect_success 'find commit 1' 'grep "commit 1" tmp'
test_expect_success 'find commit 5' 'grep "commit 5" tmp'
test_expect_success 'find branch master' 'grep "master" tmp'
test_expect_success 'no tags' '! grep "Tag</th>" tmp'
test_expect_success 'clone-url expanded correctly' '
grep "git://example.org/foo.git" tmp
'
test_expect_success 'generate bar summary' 'cgit_url "bar" >tmp'
test_expect_success 'repo description reaches the meta tag' '
grep "<meta name=.description. content=.the bar repo.>" tmp
'
test_expect_success 'no commit 45' '! grep "commit 45" tmp'
test_expect_success 'find commit 46' 'grep "commit 46" tmp'
test_expect_success 'find commit 50' 'grep "commit 50" tmp'
test_expect_success 'find branch master' 'grep "master" tmp'
test_expect_success 'no tags' '! grep "Tag</th>" tmp'
test_expect_success 'clone-url expanded correctly' '
grep "git://example.org/bar.git" tmp
'
test_expect_success 'a git clone url row falls back to the page url' '
grep "clone-url.><a rel=.vcs-git. title=.bar Git repository. href=./bar/.>git://example.org/bar.git</a>" tmp
'
test_expect_success 'an scp clone url row links to the http url' '
{
echo "virtual-root=/" &&
echo "cache-size=0" &&
echo "repo.url=foo" &&
echo "repo.path=$PWD/repos/foo/.git" &&
echo "repo.clone-url=git@example.org:foo https://example.org/foo"
} >clonerc &&
CGIT_CONFIG="$PWD/clonerc" QUERY_STRING="url=foo" cgit >tmp &&
grep "title=.foo Git repository. href=.https://example.org/foo.>git@example.org:foo</a>" tmp &&
grep "vcs-git. href=.https://example.org/foo." tmp &&
! grep "vcs-git. href=.git@" tmp
'
row_widths() {
sed -n "/<table class='list/,/<\/table>/p" "$1" | awk '
/^<tr[ >]/ {
width = 0
row = $0
while (match(row, /<t[dh][ >]/)) {
row = substr(row, RSTART + 3)
cell = substr(row, 1, index(row, ">"))
if (match(cell, /colspan=.[0-9]+/))
width += substr(cell, RSTART + 9, RLENGTH - 9)
else
width++
}
print width
}
'
}
test_widths() {
CGIT_CONFIG="$PWD/${3:-colsrc}" QUERY_STRING="url=$1" cgit >tmp &&
row_widths tmp | sort -u >actual &&
echo "$2" >expect &&
test_cmp expect actual
}
test_expect_success 'set up a repo cut short in every section' '
mkrepo repos/cols 3 >/dev/null &&
git -C repos/cols branch other HEAD~1 &&
git -C repos/cols tag one HEAD~1 &&
git -C repos/cols tag -a -m two two &&
{
echo "virtual-root=/" &&
echo "cache-size=0" &&
echo "summary-branches=1" &&
echo "summary-tags=1" &&
echo "summary-log=2" &&
echo "max-ref-count=1" &&
echo "clone-url=https://example.org/\$CGIT_REPO_URL" &&
echo "repo.url=none" &&
echo "repo.path=$PWD/repos/cols/.git" &&
echo "repo.url=lines" &&
echo "repo.path=$PWD/repos/cols/.git" &&
echo "repo.enable-log-linecount=1" &&
echo "repo.url=both" &&
echo "repo.path=$PWD/repos/cols/.git" &&
echo "repo.enable-log-filecount=1" &&
echo "repo.enable-log-linecount=1"
} >colsrc &&
CGIT_CONFIG="$PWD/colsrc" QUERY_STRING="url=none" cgit >tmp &&
grep "<tbody class=.tags.>" tmp &&
grep "<tbody class=.clone.>" tmp &&
test $(grep -c ">\[...\]</a>" tmp) = 3
'
test_expect_success 'a summary without counts fills four columns' 'test_widths none 4'
test_expect_success 'a summary with one count fills four columns' 'test_widths lines 4'
test_expect_success 'a summary with both counts fills five columns' 'test_widths both 5'
test_expect_success 'a summary without a log fills four columns' '
sed "s/^summary-log=2$/summary-log=0/" colsrc >nologrc &&
test_widths both 4 nologrc
'
test_expect_success 'the refs page fills four columns' 'test_widths both/refs/ 4'
test_expect_success 'a page of branches fills four columns' 'test_widths both/refs/heads 4'
test_expect_success 'a page of tags fills four columns' 'test_widths both/refs/tags 4'
test_done
|