t/test-lib-functions.sh: allow to specify the tag name to test_commit
[gitweb.git] / t / test-lib-functions.sh
index 9bc57d27e961720c98f75f95ab3186723e77f88b..7c4c6335925d6fa1d383e7623ce937969b13cd79 100644 (file)
@@ -135,20 +135,31 @@ test_pause () {
        fi
 }
 
-# Call test_commit with the arguments "<message> [<file> [<contents>]]"
+# Call test_commit with the arguments "<message> [<file> [<contents> [<tag>]]]"
 #
 # This will commit a file with the given contents and the given commit
-# message.  It will also add a tag with <message> as name.
+# message, and tag the resulting commit with the given tag name.
 #
-# Both <file> and <contents> default to <message>.
+# <file>, <contents>, and <tag> all default to <message>.
 
 test_commit () {
        notick= &&
-       if test "z$1" = "z--notick"
-       then
-               notick=yes
+       signoff= &&
+       while test $# != 0
+       do
+               case "$1" in
+               --notick)
+                       notick=yes
+                       ;;
+               --signoff)
+                       signoff="$1"
+                       ;;
+               *)
+                       break
+                       ;;
+               esac
                shift
-       fi &&
+       done &&
        file=${2:-"$1.t"} &&
        echo "${3-$1}" > "$file" &&
        git add "$file" &&
@@ -156,8 +167,8 @@ test_commit () {
        then
                test_tick
        fi &&
-       git commit -m "$1" &&
-       git tag "$1"
+       git commit $signoff -m "$1" &&
+       git tag "${4:-$1}"
 }
 
 # Call test_merge with the arguments "<message> <commit>", where <commit>