Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 3 | test_description='Check content on patch page' |
Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 4 | . ./setup.sh |
| 5 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 6 | test_expect_success 'generate foo/patch' ' |
| 7 | cgit_query "url=foo/patch" >tmp |
Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 8 | ' |
| 9 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 10 | test_expect_success 'find `From:` line' ' |
| 11 | grep "^From: " tmp |
Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 12 | ' |
| 13 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 14 | test_expect_success 'find `Date:` line' ' |
| 15 | grep "^Date: " tmp |
Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 16 | ' |
| 17 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 18 | test_expect_success 'find `Subject:` line' ' |
| 19 | grep "^Subject: commit 5" tmp |
Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 20 | ' |
| 21 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 22 | test_expect_success 'find `cgit` signature' ' |
Lukas Fleischer | 8408585 | 2013-08-26 20:38:33 +0200 | [diff] [blame] | 23 | tail -2 tmp | head -1 | grep "^cgit" |
Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 24 | ' |
| 25 | |
Lukas Fleischer | b5b1f07 | 2013-08-26 20:38:34 +0200 | [diff] [blame] | 26 | test_expect_success 'compare with output of git-format-patch(1)' ' |
John Keeping | ce8f490 | 2014-12-28 13:10:32 +0000 | [diff] [blame] | 27 | CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../VERSION) && |
John Keeping | 7552266 | 2014-12-28 13:10:33 +0000 | [diff] [blame] | 28 | git --git-dir="$PWD/repos/foo/.git" format-patch --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD^ >tmp2 && |
John Keeping | ce8f490 | 2014-12-28 13:10:32 +0000 | [diff] [blame] | 29 | strip_headers <tmp >tmp_ && |
| 30 | test_cmp tmp_ tmp2 |
Lukas Fleischer | b5b1f07 | 2013-08-26 20:38:34 +0200 | [diff] [blame] | 31 | ' |
| 32 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 33 | test_expect_success 'find initial commit' ' |
Lukas Fleischer | 370535f | 2013-08-26 20:38:31 +0200 | [diff] [blame] | 34 | root=$(git --git-dir="$PWD/repos/foo/.git" rev-list --max-parents=0 HEAD) |
Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 35 | ' |
| 36 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 37 | test_expect_success 'generate patch for initial commit' ' |
| 38 | cgit_query "url=foo/patch&id=$root" >tmp |
Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 39 | ' |
| 40 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 41 | test_expect_success 'find `cgit` signature' ' |
Lukas Fleischer | 8408585 | 2013-08-26 20:38:33 +0200 | [diff] [blame] | 42 | tail -2 tmp | head -1 | grep "^cgit" |
Lars Hjemli | e01f140 | 2008-03-17 23:13:16 +0100 | [diff] [blame] | 43 | ' |
Mark Lodato | c94414a | 2010-08-26 22:02:03 -0400 | [diff] [blame] | 44 | |
Lukas Fleischer | 5a88627 | 2013-08-26 20:38:35 +0200 | [diff] [blame] | 45 | test_expect_success 'generate patches for multiple commits' ' |
John Keeping | ce8f490 | 2014-12-28 13:10:32 +0000 | [diff] [blame] | 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) && |
Lukas Fleischer | 5a88627 | 2013-08-26 20:38:35 +0200 | [diff] [blame] | 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)' ' |
John Keeping | ce8f490 | 2014-12-28 13:10:32 +0000 | [diff] [blame] | 56 | CGIT_VERSION=$(sed -n "s/CGIT_VERSION = //p" ../../VERSION) && |
John Keeping | 7552266 | 2014-12-28 13:10:33 +0000 | [diff] [blame] | 57 | git --git-dir="$PWD/repos/foo/.git" format-patch -N --subject-prefix="" --signature="cgit $CGIT_VERSION" --stdout HEAD~3..HEAD >tmp2 && |
John Keeping | ce8f490 | 2014-12-28 13:10:32 +0000 | [diff] [blame] | 58 | strip_headers <tmp >tmp_ && |
| 59 | test_cmp tmp_ tmp2 |
Lukas Fleischer | 5a88627 | 2013-08-26 20:38:35 +0200 | [diff] [blame] | 60 | ' |
| 61 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 62 | test_done |