all repos — cgit @ 5fe88a9c81517b1a8a93d930c738cbb6f71dec2a

a hyperfast web frontend for git written in c

tests/t0108-patch.sh (view raw)

 1#!/bin/sh
 2
 3test_description='Check content on patch page'
 4. ./setup.sh
 5
 6test_expect_success 'generate foo/patch' '
 7	cgit_query "url=foo/patch" >tmp
 8'
 9
10test_expect_success 'find `From:` line' '
11	grep "^From: " tmp
12'
13
14test_expect_success 'find `Date:` line' '
15	grep "^Date: " tmp
16'
17
18test_expect_success 'find `Subject:` line' '
19	grep "^Subject: commit 5" tmp
20'
21
22test_expect_success 'find `cgit` signature' '
23	tail -2 tmp | head -1 | grep "^cgit"
24'
25
26test_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
33test_expect_success 'find initial commit' '
34	root=$(git --git-dir="$PWD/repos/foo/.git" rev-list --max-parents=0 HEAD)
35'
36
37test_expect_success 'generate patch for initial commit' '
38	cgit_query "url=foo/patch&id=$root" >tmp
39'
40
41test_expect_success 'find `cgit` signature' '
42	tail -2 tmp | head -1 | grep "^cgit"
43'
44
45test_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
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)' '
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
62test_done