| 1 |
From: Reinhard Tartler <[email protected]> |
| 2 |
Date: Wed, 12 Aug 2026 07:57:31 +0200 |
| 3 |
Subject: Use xstrings.ToPascalCase for camelcase function |
| 4 |
|
| 5 |
camelcase used to call xstrings.ToCamelCase, but that function had a |
| 6 |
breaking change in xstrings version 1.5 that moved it from upper camel |
| 7 |
case to lower camel case. This breaks sprig's public API. A new |
| 8 |
xstrings.ToPascalCase function was added that provides upper camel case. |
| 9 |
|
| 10 |
Backport of upstream commit fe8e5b9 (sprig v3.3.0). Closes: #1143319 |
| 11 |
|
| 12 |
Forwarded: https://github.com/Masterminds/sprig/commit/fe8e5b963cddb929b1ba4a9684401a84f382845a |
| 13 |
--- |
| 14 |
functions.go | 11 +++++++---- |
| 15 |
1 file changed, 7 insertions(+), 4 deletions(-) |
| 16 |
|
| 17 |
diff --git a/functions.go b/functions.go |
| 18 |
index 57fcec1..5dd9c28 100644 |
| 19 |
--- a/functions.go |
| 20 |
+++ b/functions.go |
| 21 |
@@ -142,10 +142,13 @@ var genericMap = map[string]interface{}{ |
| 22 |
"swapcase": util.SwapCase, |
| 23 |
"shuffle": xstrings.Shuffle, |
| 24 |
"snakecase": xstrings.ToSnakeCase, |
| 25 |
- "camelcase": xstrings.ToCamelCase, |
| 26 |
- "kebabcase": xstrings.ToKebabCase, |
| 27 |
- "wrap": func(l int, s string) string { return util.Wrap(s, l) }, |
| 28 |
- "wrapWith": func(l int, sep, str string) string { return util.WrapCustom(str, l, sep, true) }, |
| 29 |
+ // camelcase used to call xstrings.ToCamelCase, but that function had a breaking change in version |
| 30 |
+ // 1.5 that moved it from upper camel case to lower camel case. This is a breaking change for sprig. |
| 31 |
+ // A new xstrings.ToPascalCase function was added that provided upper camel case. |
| 32 |
+ "camelcase": xstrings.ToPascalCase, |
| 33 |
+ "kebabcase": xstrings.ToKebabCase, |
| 34 |
+ "wrap": func(l int, s string) string { return util.Wrap(s, l) }, |
| 35 |
+ "wrapWith": func(l int, sep, str string) string { return util.WrapCustom(str, l, sep, true) }, |
| 36 |
// Switch order so that "foobar" | contains "foo" |
| 37 |
"contains": func(substr string, str string) bool { return strings.Contains(str, substr) }, |
| 38 |
"hasPrefix": func(substr string, str string) bool { return strings.HasPrefix(str, substr) }, |