Skip to content

Commit fd8a489

Browse files
committed
tests: commit-msg hook from subdir
1 parent 5f8cce4 commit fd8a489

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

t/t7504-commit-msg-hook.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ test_expect_success 'refresh --no-verify with non-executable hook (editor)' '
270270

271271
# now a hook that edits the commit message
272272
write_script "$HOOK" <<-'EOF'
273-
echo "new message" >"$1"
273+
if test -d .git; then
274+
echo "new message" >"$1"
275+
else
276+
echo "not in work root" >"$1"
277+
fi
274278
exit 0
275279
EOF
276280

@@ -279,6 +283,16 @@ test_expect_success 'new hook edits commit message' '
279283
commit_msg_is "new message"
280284
'
281285

286+
test_expect_success 'commit-msg run from subdir' '
287+
mkdir -p dir0/dir1 &&
288+
(
289+
cd dir0/dir1 &&
290+
stg new -m from-subdir
291+
) &&
292+
commit_msg_is "new message" &&
293+
stg delete from-subdir
294+
'
295+
282296
test_expect_success "new hook doesn't edit commit message" '
283297
stg new --no-verify -m "plus" plus &&
284298
commit_msg_is "plus"

0 commit comments

Comments
 (0)