aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tests/t0105-commit.sh
blob: 9cdf55c02576cbcd596afcd43e41a074e5611179 (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
#!/bin/sh

test_description='Check content on commit page'
. ./setup.sh

test_expect_success 'generate foo/commit' 'cgit_url "foo/commit" >tmp'
test_expect_success 'find tree link' 'grep "<a href=./foo/tree/.>" tmp'
test_expect_success 'find parent link' 'grep -E "<a href=./foo/commit/\?id=.+>" tmp'

test_expect_success 'find commit subject' '
	grep "<div class=.commit-subject.>commit 5<" tmp
'

test_expect_success 'find commit msg' 'grep "<div class=.commit-msg.></div>" tmp'
test_expect_success 'find diffstat' 'grep "<table summary=.diffstat. class=.diffstat.>" tmp'

test_expect_success 'find diff summary' '
	grep "1 files changed, 1 insertions, 0 deletions" tmp
'

test_expect_success 'get root commit' '
	root=$(cd repos/foo && git rev-list --reverse HEAD | head -1) &&
	cgit_url "foo/commit&id=$root" >tmp &&
	grep "</html>" tmp
'

test_expect_success 'root commit contains diffstat' '
	grep "<a href=./foo/diff/file-1.id=[0-9a-f]\{40\}.>file-1</a>" tmp
'

test_expect_success 'root commit contains diff' '
	grep ">diff --git a/file-1 b/file-1<" tmp &&
	grep "<div class=.add.>+1</div>" tmp
'

test_done
span class="w"> ' cgit_query "url=foo/patch&id=$root" >tmp ' test_expect_success 'find `cgit` signature' ' tail -2 tmp | head -1 | grep "^cgit" ' test_expect_success 'generate patches for multiple commits' ' id=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD) id2=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD~3) cgit_query "url=foo/patch&id=$id&id2=$id2" >tmp ' test_expect_success 'find `cgit` signature' ' tail -2 tmp | head -1 | grep "^cgit" ' test_expect_success 'compare with output of git-format-patch(1)' ' CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../VERSION) git --git-dir="$PWD/repos/foo/.git" format-patch -p -N --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD~3..HEAD >tmp2 sed "1,5d" tmp >tmp_ cmp tmp_ tmp2 ' test_done