Thread (13 messages) flat view 13 messages, 3 authors, 2016-06-15

Re: [PATCH 1/2 v2] test-lib.sh: introduce 4th argument to test_commit() specifying a tag name

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2016-06-15 22:49:13

On Sat, Jul 31, 2010 at 01:56, Dmitry V. Levin [off-list ref] wrote:
quoted hunk ↗ jump to hunk
When fourth argument to test_commit() is specified, use it as a tag
name, unless it equals to empty string.  In the latter case, skip tag
creation.

Suggested-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Dmitry V. Levin <redacted>
---
 t/README      |    8 ++++----
 t/test-lib.sh |   11 ++++++++---
 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/t/README b/t/README
index 0d1183c..18f5810 100644
--- a/t/README
+++ b/t/README
@@ -388,13 +388,13 @@ library for your script to use.
   committer times to defined stated.  Subsequent calls will
   advance the times by a fixed amount.

- - test_commit <message> [<filename> [<contents>]]
+ - test_commit <message> [<filename> [<contents> [<tagname>]]]

   Creates a commit with the given message, committing the given
   file with the given contents (default for both is to reuse the
-   message string), and adds a tag (again reusing the message
-   string as name).  Calls test_tick to make the SHA-1s
-   reproducible.
+   message string), and adds a tag with the given name (default again
+   is to reuse the message string as name) unless this name is the
+   empty string.  Calls test_tick to make the SHA-1s reproducible.

 - test_merge <message> <commit-or-tag>
diff --git a/t/test-lib.sh b/t/test-lib.sh
index e5523dd..ebb6215 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -277,10 +277,12 @@ test_tick () {
       export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
 }

-# Call test_commit with the arguments "<message> [<file> [<contents>]]"
+# Call test_commit with the arguments
+# "<message> [<file> [<contents> [<tagname>]]]"
 #
 # 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.  It will also add a tag with the given name unless the latter
+# is the empty string.
 #
 # Both <file> and <contents> default to <message>.
@@ -290,7 +292,10 @@ test_commit () {
       git add "$file" &&
       test_tick &&
       git commit -m "$1" &&
-       git tag "$1"
+       if test -n "${4-$1}"
+       then
+               git tag "${4-$1}"
+       fi
 }

 # Call test_merge with the arguments "<message> <commit>", where <commit>
This one looks good, thanks.

Acked-by: Ævar Arnfjörð Bjarmason <redacted>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help