t/t3437: simplify and document the test helpers
Let's simplify the test_commit_message() helper function and add comments to the function. This patch also document the working of 'fixup -C' with "amend!" in the test-description. Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Charvi Mendiratta <charvi077@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4755fed0a6
commit
d8bd08066d
@ -9,7 +9,9 @@ This test checks the "fixup [-C|-c]" command of rebase interactive.
|
|||||||
In addition to amending the contents of the commit, "fixup -C"
|
In addition to amending the contents of the commit, "fixup -C"
|
||||||
replaces the original commit message with the message of the fixup
|
replaces the original commit message with the message of the fixup
|
||||||
commit. "fixup -c" also replaces the original message, but opens the
|
commit. "fixup -c" also replaces the original message, but opens the
|
||||||
editor to allow the user to edit the message before committing.
|
editor to allow the user to edit the message before committing. Similar
|
||||||
|
to the "fixup" command that works with "fixup!", "fixup -C" works with
|
||||||
|
"amend!" upon --autosquash.
|
||||||
'
|
'
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
@ -18,17 +20,19 @@ editor to allow the user to edit the message before committing.
|
|||||||
|
|
||||||
EMPTY=""
|
EMPTY=""
|
||||||
|
|
||||||
|
# test_commit_message <rev> -m <msg>
|
||||||
|
# test_commit_message <rev> <path>
|
||||||
|
# Verify that the commit message of <rev> matches
|
||||||
|
# <msg> or the content of <path>.
|
||||||
test_commit_message () {
|
test_commit_message () {
|
||||||
rev="$1" && # commit or tag we want to test
|
git show --no-patch --pretty=format:%B "$1" >actual &&
|
||||||
file="$2" && # test against the content of a file
|
case "$2" in
|
||||||
git show --no-patch --pretty=format:%B "$rev" >actual-message &&
|
-m)
|
||||||
if test "$2" = -m
|
echo "$3" >expect &&
|
||||||
then
|
test_cmp expect actual ;;
|
||||||
str="$3" && # test against a string
|
*)
|
||||||
printf "%s\n" "$str" >tmp-expected-message &&
|
test_cmp "$2" actual ;;
|
||||||
file="tmp-expected-message"
|
esac
|
||||||
fi
|
|
||||||
test_cmp "$file" actual-message
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get_author () {
|
get_author () {
|
||||||
|
Loading…
Reference in New Issue
Block a user