~ubuntu-branches/ubuntu/edgy/git-core/edgy-backports

« back to all changes in this revision

Viewing changes to t/t7500-commit.sh

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2007-11-29 07:28:44 UTC
  • mfrom: (8.1.2 dapper-backports)
  • Revision ID: package-import@ubuntu.com-20071129072844-umsb7y3140yhxkth
Tags: 1:1.5.3.6-1.1~dapper1
* backport to dapper et al.
  - debian/rules changes to support source:Upstream-Version for old dpkg.
  - allow asciidoc (>7.0.2-3)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Copyright (c) 2007 Steven Grimm
 
4
#
 
5
 
 
6
test_description='git-commit
 
7
 
 
8
Tests for selected commit options.'
 
9
 
 
10
. ./test-lib.sh
 
11
 
 
12
commit_msg_is () {
 
13
        test "`git log --pretty=format:%s%b -1`" = "$1"
 
14
}
 
15
 
 
16
# A sanity check to see if commit is working at all.
 
17
test_expect_success 'a basic commit in an empty tree should succeed' '
 
18
        echo content > foo &&
 
19
        git add foo &&
 
20
        git commit -m "initial commit"
 
21
'
 
22
 
 
23
test_expect_success 'nonexistent template file should return error' '
 
24
        echo changes >> foo &&
 
25
        git add foo &&
 
26
        ! git commit --template "$PWD"/notexist
 
27
'
 
28
 
 
29
test_expect_success 'nonexistent template file in config should return error' '
 
30
        git config commit.template "$PWD"/notexist &&
 
31
        ! git commit &&
 
32
        git config --unset commit.template
 
33
'
 
34
 
 
35
# From now on we'll use a template file that exists.
 
36
TEMPLATE="$PWD"/template
 
37
 
 
38
test_expect_success 'unedited template should not commit' '
 
39
        echo "template line" > "$TEMPLATE" &&
 
40
        ! git commit --template "$TEMPLATE"
 
41
'
 
42
 
 
43
test_expect_success 'unedited template with comments should not commit' '
 
44
        echo "# comment in template" >> "$TEMPLATE" &&
 
45
        ! git commit --template "$TEMPLATE"
 
46
'
 
47
 
 
48
test_expect_success 'a Signed-off-by line by itself should not commit' '
 
49
        ! GIT_EDITOR=../t7500/add-signed-off git commit --template "$TEMPLATE"
 
50
'
 
51
 
 
52
test_expect_success 'adding comments to a template should not commit' '
 
53
        ! GIT_EDITOR=../t7500/add-comments git commit --template "$TEMPLATE"
 
54
'
 
55
 
 
56
test_expect_success 'adding real content to a template should commit' '
 
57
        GIT_EDITOR=../t7500/add-content git commit --template "$TEMPLATE" &&
 
58
        commit_msg_is "template linecommit message"
 
59
'
 
60
 
 
61
test_expect_success '-t option should be short for --template' '
 
62
        echo "short template" > "$TEMPLATE" &&
 
63
        echo "new content" >> foo &&
 
64
        git add foo &&
 
65
        GIT_EDITOR=../t7500/add-content git commit -t "$TEMPLATE" &&
 
66
        commit_msg_is "short templatecommit message"
 
67
'
 
68
 
 
69
test_expect_success 'config-specified template should commit' '
 
70
        echo "new template" > "$TEMPLATE" &&
 
71
        git config commit.template "$TEMPLATE" &&
 
72
        echo "more content" >> foo &&
 
73
        git add foo &&
 
74
        GIT_EDITOR=../t7500/add-content git commit &&
 
75
        git config --unset commit.template &&
 
76
        commit_msg_is "new templatecommit message"
 
77
'
 
78
 
 
79
test_expect_success 'explicit commit message should override template' '
 
80
        echo "still more content" >> foo &&
 
81
        git add foo &&
 
82
        GIT_EDITOR=../t7500/add-content git commit --template "$TEMPLATE" \
 
83
                -m "command line msg" &&
 
84
        commit_msg_is "command line msg<unknown>"
 
85
'
 
86
 
 
87
test_expect_success 'commit message from file should override template' '
 
88
        echo "content galore" >> foo &&
 
89
        git add foo &&
 
90
        echo "standard input msg" |
 
91
                GIT_EDITOR=../t7500/add-content git commit \
 
92
                        --template "$TEMPLATE" --file - &&
 
93
        commit_msg_is "standard input msg<unknown>"
 
94
'
 
95
 
 
96
test_done