tg export: no need for merge or hook setup
[topgit/pro.git] / t / t2110-create-no-edit.sh
blob3d345bf6a1f3e0c4474b9831f50d5163eb3d1f53
1 #!/bin/sh
3 test_description='test --no-edit and --topmsg etc. modes of tg create'
5 TEST_NO_CREATE_REPO=1
7 . ./test-lib.sh
9 test_recreate_repo_cd() {
10 ! [ -e "$1" ] || rm -rf "$1"
11 ! [ -e "$1" ] || { chmod -R u+rw "$1"; rm -rf "$1"; }
12 ! [ -e "$1" ] || die
13 test_create_repo "$1" &&
14 cd "$1"
17 tmf="$(test_get_temp topmsg)" || die
19 test_plan 12
21 test_expect_success 'root create --topmsg with "subject:"' '
22 test_recreate_repo_cd r0 &&
23 tg create --no-deps --topmsg " SuBjEcT : My Subject " HEAD &&
24 printf "%s\n" "SuBjEcT : My Subject" >expect &&
25 test_diff expect .topmsg
28 test_expect_success 'root create --topmsg without "subject:"' '
29 test_recreate_repo_cd r0 &&
30 tg create --no-deps --topmsg " My Subject " HEAD &&
31 printf "%s\n" "Subject: [ROOT] My Subject" >expect &&
32 test_diff expect .topmsg
35 test_expect_success 'root create --topmsg-file with "subject:"' '
36 test_recreate_repo_cd r0 &&
37 printf "%s\n" "From: somewhere" "Out: there" "sUbJeCt : My Subj " "#more" >"$tmf" &&
38 tg create --no-deps --topmsg-file "$tmf" HEAD &&
39 git stripspace <"$tmf" >expect &&
40 test_diff expect .topmsg
43 test_expect_success 'root create --topmsg-file without "subject:"' '
44 test_recreate_repo_cd r0 &&
45 printf "%s\n" "From: somewhere" "Out: there" "" "sUbJeCt : My Subj " "#more" >"$tmf" &&
46 tg create --no-deps --topmsg-file "$tmf" HEAD &&
47 # this is very ugly, but it is not a freaking AI!
48 { printf "%s\n" "Subject: [ROOT] From: somewhere" "" &&
49 sed -n "2,\$p" <"$tmf"; } | git stripspace >expect &&
50 test_diff expect .topmsg
53 test_expect_success 'base create --topmsg with "subject:"' '
54 test_recreate_repo_cd r0 &&
55 test_commit first^one &&
56 tg create --no-deps --topmsg " SuBjEcT : My Subject " tgb &&
57 printf "%s\n" "SuBjEcT : My Subject" >expect &&
58 test_diff expect .topmsg
61 test_expect_success 'base create --topmsg without "subject:"' '
62 test_recreate_repo_cd r0 &&
63 test_commit first^one &&
64 tg create --no-deps --topmsg " My Subject " tgb &&
65 printf "%s\n" "Subject: [BASE] My Subject" >expect &&
66 test_diff expect .topmsg
69 test_expect_success 'patch create --topmsg with "subject:"' '
70 test_recreate_repo_cd r0 &&
71 test_commit first^one &&
72 tg create --topmsg " SuBjEcT : My Subject " tgb &&
73 printf "%s\n" "SuBjEcT : My Subject" >expect &&
74 test_diff expect .topmsg
77 test_expect_success 'patch create --topmsg without "subject:"' '
78 test_recreate_repo_cd r0 &&
79 test_commit first^one &&
80 tg create --topmsg " My Subject " tgb &&
81 printf "%s\n" "Subject: [PATCH] My Subject" >expect &&
82 test_diff expect .topmsg
85 test_expect_success 'patch create --no-edit' '
86 test_recreate_repo_cd r0 &&
87 test_commit first^one &&
88 bcnt="$(git rev-list --count --all)" &&
89 EDITOR="echo x >" && export EDITOR &&
90 tg create --no-edit tgb &&
91 acnt="$(git rev-list --count --all)" &&
92 test $acnt -gt $bcnt &&
93 printf "%s" "\
94 From: Te s t (Author) <test@example.net>
95 Subject: [PATCH] tgb
96 " >expect &&
97 test_diff expect .topmsg
100 test_expect_success 'patch create EDITOR=:' '
101 test_recreate_repo_cd r0 &&
102 test_commit first^one &&
103 bcnt="$(git rev-list --count --all)" &&
104 EDITOR=: && export EDITOR &&
105 tg create tgb &&
106 acnt="$(git rev-list --count --all)" &&
107 test $acnt -gt $bcnt &&
108 printf "%s" "\
109 From: Te s t (Author) <test@example.net>
110 Subject: [PATCH] tgb
111 " >expect &&
112 test_diff expect .topmsg
115 test_expect_success 'format.signoff=true patch create --no-edit' '
116 test_recreate_repo_cd r0 &&
117 test_commit first^one &&
118 bcnt="$(git rev-list --count --all)" &&
119 EDITOR="echo x >" && export EDITOR &&
120 tg -c format.signoff=1 create --no-edit tgb &&
121 acnt="$(git rev-list --count --all)" &&
122 test $acnt -gt $bcnt &&
123 printf "%s" "\
124 From: Te s t (Author) <test@example.net>
125 Subject: [PATCH] tgb
127 Signed-off-by: Te s t (Author) <test@example.net>
128 " >expect &&
129 test_diff expect .topmsg
132 test_expect_success 'format.signoff=true patch create EDITOR=:' '
133 test_recreate_repo_cd r0 &&
134 test_commit first^one &&
135 EDITOR=":" && export EDITOR &&
136 bcnt="$(git rev-list --count --all)" &&
137 tg -c format.signoff=1 create tgb &&
138 acnt="$(git rev-list --count --all)" &&
139 test $acnt -gt $bcnt &&
140 printf "%s" "\
141 From: Te s t (Author) <test@example.net>
142 Subject: [PATCH] tgb
144 Signed-off-by: Te s t (Author) <test@example.net>
145 " >expect &&
146 test_diff expect .topmsg
149 test_done