Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 1fc4f97

Browse files
benoit-pierregitster
authored andcommitted
merge hook tests: fix and update tests
- update 'no editor' hook test and add 'editor' hook test - make sure the tree is reset to a clean state after running a test (using test_when_finished) so later tests are not impacted Signed-off-by: Benoit Pierre <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0a3beb0 commit 1fc4f97

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

t/t7505-prepare-commit-msg-hook.sh

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,26 @@ test_expect_success 'with hook (-c)' '
134134

135135
test_expect_success 'with hook (merge)' '
136136
137-
head=`git rev-parse HEAD` &&
138-
git checkout -b other HEAD@{1} &&
139-
echo "more" >> file &&
137+
test_when_finished "git checkout -f master" &&
138+
git checkout -B other HEAD@{1} &&
139+
echo "more" >>file &&
140+
git add file &&
141+
git commit -m other &&
142+
git checkout - &&
143+
git merge --no-ff other &&
144+
test "`git log -1 --pretty=format:%s`" = "merge (no editor)"
145+
'
146+
147+
test_expect_success 'with hook and editor (merge)' '
148+
149+
test_when_finished "git checkout -f master" &&
150+
git checkout -B other HEAD@{1} &&
151+
echo "more" >>file &&
140152
git add file &&
141153
git commit -m other &&
142154
git checkout - &&
143-
git merge other &&
144-
test "`git log -1 --pretty=format:%s`" = merge
155+
env GIT_EDITOR="\"\$FAKE_EDITOR\"" git merge --no-ff -e other &&
156+
test "`git log -1 --pretty=format:%s`" = "merge"
145157
'
146158

147159
cat > "$HOOK" <<'EOF'
@@ -151,6 +163,7 @@ EOF
151163

152164
test_expect_success 'with failing hook' '
153165
166+
test_when_finished "git checkout -f master" &&
154167
head=`git rev-parse HEAD` &&
155168
echo "more" >> file &&
156169
git add file &&
@@ -160,6 +173,7 @@ test_expect_success 'with failing hook' '
160173

161174
test_expect_success 'with failing hook (--no-verify)' '
162175
176+
test_when_finished "git checkout -f master" &&
163177
head=`git rev-parse HEAD` &&
164178
echo "more" >> file &&
165179
git add file &&
@@ -169,6 +183,7 @@ test_expect_success 'with failing hook (--no-verify)' '
169183

170184
test_expect_success 'with failing hook (merge)' '
171185
186+
test_when_finished "git checkout -f master" &&
172187
git checkout -B other HEAD@{1} &&
173188
echo "more" >> file &&
174189
git add file &&
@@ -178,7 +193,7 @@ test_expect_success 'with failing hook (merge)' '
178193
exit 1
179194
EOF
180195
git checkout - &&
181-
test_must_fail git merge other
196+
test_must_fail git merge --no-ff other
182197
183198
'
184199

0 commit comments

Comments
 (0)