blob: 013d68024d5df8ef1ad8764de80a9d65d624a525 [file] [log] [blame]
Lars Hjemlie01f1402008-03-17 23:13:16 +01001#!/bin/sh
2
John Keepingc95cc5e2013-04-01 15:09:05 +01003test_description='Check content on patch page'
Lars Hjemlie01f1402008-03-17 23:13:16 +01004. ./setup.sh
5
John Keepingc95cc5e2013-04-01 15:09:05 +01006test_expect_success 'generate foo/patch' '
7 cgit_query "url=foo/patch" >tmp
Lars Hjemlie01f1402008-03-17 23:13:16 +01008'
9
John Keepingc95cc5e2013-04-01 15:09:05 +010010test_expect_success 'find `From:` line' '
11 grep "^From: " tmp
Lars Hjemlie01f1402008-03-17 23:13:16 +010012'
13
John Keepingc95cc5e2013-04-01 15:09:05 +010014test_expect_success 'find `Date:` line' '
15 grep "^Date: " tmp
Lars Hjemlie01f1402008-03-17 23:13:16 +010016'
17
John Keepingc95cc5e2013-04-01 15:09:05 +010018test_expect_success 'find `Subject:` line' '
19 grep "^Subject: commit 5" tmp
Lars Hjemlie01f1402008-03-17 23:13:16 +010020'
21
John Keepingc95cc5e2013-04-01 15:09:05 +010022test_expect_success 'find `cgit` signature' '
Lukas Fleischer84085852013-08-26 20:38:33 +020023 tail -2 tmp | head -1 | grep "^cgit"
Lars Hjemlie01f1402008-03-17 23:13:16 +010024'
25
Lukas Fleischerb5b1f072013-08-26 20:38:34 +020026test_expect_success 'compare with output of git-format-patch(1)' '
John Keepingce8f4902014-12-28 13:10:32 +000027 CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../VERSION) &&
John Keeping75522662014-12-28 13:10:33 +000028 git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD^ >tmp2 &&
John Keepingce8f4902014-12-28 13:10:32 +000029 strip_headers <tmp >tmp_ &&
30 test_cmp tmp_ tmp2
Lukas Fleischerb5b1f072013-08-26 20:38:34 +020031'
32
John Keepingc95cc5e2013-04-01 15:09:05 +010033test_expect_success 'find initial commit' '
Lukas Fleischer370535f2013-08-26 20:38:31 +020034 root=$(git --git-dir="$PWD/repos/foo/.git" rev-list --max-parents=0 HEAD)
Lars Hjemlie01f1402008-03-17 23:13:16 +010035'
36
John Keepingc95cc5e2013-04-01 15:09:05 +010037test_expect_success 'generate patch for initial commit' '
38 cgit_query "url=foo/patch&id=$root" >tmp
Lars Hjemlie01f1402008-03-17 23:13:16 +010039'
40
John Keepingc95cc5e2013-04-01 15:09:05 +010041test_expect_success 'find `cgit` signature' '
Lukas Fleischer84085852013-08-26 20:38:33 +020042 tail -2 tmp | head -1 | grep "^cgit"
Lars Hjemlie01f1402008-03-17 23:13:16 +010043'
Mark Lodatoc94414a2010-08-26 22:02:03 -040044
Lukas Fleischer5a886272013-08-26 20:38:35 +020045test_expect_success 'generate patches for multiple commits' '
John Keepingce8f4902014-12-28 13:10:32 +000046 id=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD) &&
47 id2=$(git --git-dir="$PWD/repos/foo/.git" rev-parse HEAD~3) &&
Lukas Fleischer5a886272013-08-26 20:38:35 +020048 cgit_query "url=foo/patch&id=$id&id2=$id2" >tmp
49'
50
51test_expect_success 'find `cgit` signature' '
52 tail -2 tmp | head -1 | grep "^cgit"
53'
54
55test_expect_success 'compare with output of git-format-patch(1)' '
John Keepingce8f4902014-12-28 13:10:32 +000056 CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../VERSION) &&
John Keeping75522662014-12-28 13:10:33 +000057 git --git-dir="$PWD/repos/foo/.git" format-patch -N --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD~3..HEAD >tmp2 &&
John Keepingce8f4902014-12-28 13:10:32 +000058 strip_headers <tmp >tmp_ &&
59 test_cmp tmp_ tmp2
Lukas Fleischer5a886272013-08-26 20:38:35 +020060'
61
John Keepingc95cc5e2013-04-01 15:09:05 +010062test_done