aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gotest.tools/internal/format/format.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-29 20:41:19 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-29 20:41:19 +0200
commitc46d01f8c10e6363b680fa6876e91bd8eaf3bb3e (patch)
treedde41c1253534bf4ff36e39454f2bdbdf4b9590f /vendor/gotest.tools/internal/format/format.go
parent41e61a67b63e4d6c517005cf6f427115a664bdb5 (diff)
downloadgit-bug-c46d01f8c10e6363b680fa6876e91bd8eaf3bb3e.tar.gz
bug: implement comment edition
- add a new operation - add a new "timeline" in the snapshot that hold a processed version of the operations
Diffstat (limited to 'vendor/gotest.tools/internal/format/format.go')
-rw-r--r--vendor/gotest.tools/internal/format/format.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/vendor/gotest.tools/internal/format/format.go b/vendor/gotest.tools/internal/format/format.go
new file mode 100644
index 00000000..8f6494f9
--- /dev/null
+++ b/vendor/gotest.tools/internal/format/format.go
@@ -0,0 +1,27 @@
+package format // import "gotest.tools/internal/format"
+
+import "fmt"
+
+// Message accepts a msgAndArgs varargs and formats it using fmt.Sprintf
+func Message(msgAndArgs ...interface{}) string {
+ switch len(msgAndArgs) {
+ case 0:
+ return ""
+ case 1:
+ return fmt.Sprintf("%v", msgAndArgs[0])
+ default:
+ return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...)
+ }
+}
+
+// WithCustomMessage accepts one or two messages and formats them appropriately
+func WithCustomMessage(source string, msgAndArgs ...interface{}) string {
+ custom := Message(msgAndArgs...)
+ switch {
+ case custom == "":
+ return source
+ case source == "":
+ return custom
+ }
+ return fmt.Sprintf("%s: %s", source, custom)
+}