]> git.cameronkatri.com Git - cgit.git/blob - tests/t0108-patch.sh
auth-filters: do not crash on nil username
[cgit.git] / tests / t0108-patch.sh
1 #!/bin/sh
2
3 test_description='Check content on patch page'
4 . ./setup.sh
5
6 test_expect_success 'generate foo/patch' '
7 cgit_query "url=foo/patch" >tmp
8 '
9
10 test_expect_success 'find `From:` line' '
11 grep "^From: " tmp
12 '
13
14 test_expect_success 'find `Date:` line' '
15 grep "^Date: " tmp
16 '
17
18 test_expect_success 'find `Subject:` line' '
19 grep "^Subject: commit 5" tmp
20 '
21
22 test_expect_success 'find `cgit` signature' '
23 tail -2 tmp | head -1 | grep "^cgit"
24 '
25
26 test_expect_success 'compare with output of git-format-patch(1)' '
27 CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../VERSION) &&
28 git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD^ >tmp2 &&
29 strip_headers <tmp >tmp_ &&
30 test_cmp tmp_ tmp2
31 '
32
33 test_expect_success 'find initial commit' '
34 root=$(git --git-dir="$PWD/repos/foo/.git" rev-list --max-parents=0 HEAD)
35 '
36
37 test_expect_success 'generate patch for initial commit' '
38 cgit_query "url=foo/patch&id=$root" >tmp
39 '
40
41 test_expect_success 'find `cgit` signature' '
42 tail -2 tmp | head -1 | grep "^cgit"
43 '
44
45 test_expect_success 'generate patches for multiple commits' '
46 id=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD) &&
47 id2=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD~3) &&
48 cgit_query "url=foo/patch&id=$id&id2=$id2" >tmp
49 '
50
51 test_expect_success 'find `cgit` signature' '
52 tail -2 tmp | head -1 | grep "^cgit"
53 '
54
55 test_expect_success 'compare with output of git-format-patch(1)' '
56 CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../VERSION) &&
57 git --git-dir="$PWD/repos/foo/.git" format-patch -N --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD~3..HEAD >tmp2 &&
58 strip_headers <tmp >tmp_ &&
59 test_cmp tmp_ tmp2
60 '
61
62 test_done