test-lib functions: add an --annotated option to "test_commit"
Add an --annotated option to test_commit to create annotated tags. The tag will share the same message as the commit, and we'll call test_tick before creating it (unless --notick) is provided. There's quite a few tests that could be simplified with this construct. I've picked one to convert in this change as a demonstration. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
5144219b7d
commit
6cf8d96fa2
|
@ -7,11 +7,9 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success setup '
|
test_expect_success setup '
|
||||||
test_commit A &&
|
test_commit --annotate A &&
|
||||||
git tag -f -a -m "annotated A" A &&
|
|
||||||
git checkout -b side &&
|
git checkout -b side &&
|
||||||
test_commit B &&
|
test_commit --annotate B &&
|
||||||
git tag -f -a -m "annotated B" B &&
|
|
||||||
git checkout main &&
|
git checkout main &&
|
||||||
test_commit C &&
|
test_commit C &&
|
||||||
git branch B A^0
|
git branch B A^0
|
||||||
|
|
|
@ -179,6 +179,10 @@ debug () {
|
||||||
# Invoke "git commit" with --author <author>
|
# Invoke "git commit" with --author <author>
|
||||||
# --no-tag
|
# --no-tag
|
||||||
# Do not tag the resulting commit
|
# Do not tag the resulting commit
|
||||||
|
# --annotate
|
||||||
|
# Create an annotated tag with "--annotate -m <message>". Calls
|
||||||
|
# test_tick between making the commit and tag, unless --notick
|
||||||
|
# is given.
|
||||||
#
|
#
|
||||||
# This will commit a file with the given contents and the given commit
|
# This will commit a file with the given contents and the given commit
|
||||||
# message, and tag the resulting commit with the given tag name.
|
# message, and tag the resulting commit with the given tag name.
|
||||||
|
@ -191,7 +195,7 @@ test_commit () {
|
||||||
author= &&
|
author= &&
|
||||||
signoff= &&
|
signoff= &&
|
||||||
indir= &&
|
indir= &&
|
||||||
no_tag= &&
|
tag=light &&
|
||||||
while test $# != 0
|
while test $# != 0
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -219,7 +223,10 @@ test_commit () {
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--no-tag)
|
--no-tag)
|
||||||
no_tag=yes
|
tag=none
|
||||||
|
;;
|
||||||
|
--annotate)
|
||||||
|
tag=annotate
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
|
@ -243,10 +250,20 @@ test_commit () {
|
||||||
git ${indir:+ -C "$indir"} commit \
|
git ${indir:+ -C "$indir"} commit \
|
||||||
${author:+ --author "$author"} \
|
${author:+ --author "$author"} \
|
||||||
$signoff -m "$1" &&
|
$signoff -m "$1" &&
|
||||||
if test -z "$no_tag"
|
case "$tag" in
|
||||||
then
|
none)
|
||||||
|
;;
|
||||||
|
light)
|
||||||
git ${indir:+ -C "$indir"} tag "${4:-$1}"
|
git ${indir:+ -C "$indir"} tag "${4:-$1}"
|
||||||
fi
|
;;
|
||||||
|
annotate)
|
||||||
|
if test -z "$notick"
|
||||||
|
then
|
||||||
|
test_tick
|
||||||
|
fi &&
|
||||||
|
git ${indir:+ -C "$indir"} tag -a -m "$1" "${4:-$1}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Call test_merge with the arguments "<message> <commit>", where <commit>
|
# Call test_merge with the arguments "<message> <commit>", where <commit>
|
||||||
|
|
Loading…
Reference in New Issue