From 82f9922ec48c7bd7a133944256a9d4c9bea2ca7d Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sun, 5 Apr 2020 21:51:12 +0100 Subject: [PATCH] Include non-hermetic text functions from Sprig --- cmd/config.go | 2 +- cmd/config_test.go | 2 +- cmd/docs.gen.go | 9 ++++----- docs/HOWTO.md | 5 ++--- docs/REFERENCE.md | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index c20c217db82..035f93eeacf 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -140,7 +140,7 @@ func newConfig(options ...configOption) *Config { Command: "vimdiff", }, maxDiffDataSize: 1 * 1024 * 1024, // 1MB - templateFuncs: sprig.HermeticTxtFuncMap(), + templateFuncs: sprig.TxtFuncMap(), scriptStateBucket: []byte("script"), Stdin: os.Stdin, Stdout: os.Stdout, diff --git a/cmd/config_test.go b/cmd/config_test.go index a6c0aa21bb1..fd7dc07b1f8 100644 --- a/cmd/config_test.go +++ b/cmd/config_test.go @@ -19,7 +19,7 @@ import ( func TestAutoCommitCommitMessage(t *testing.T) { commitMessageText, err := getAsset(commitMessageTemplateAsset) require.NoError(t, err) - commitMessageTmpl, err := template.New("commit_message").Funcs(sprig.HermeticTxtFuncMap()).Parse(string(commitMessageText)) + commitMessageTmpl, err := template.New("commit_message").Funcs(sprig.TxtFuncMap()).Parse(string(commitMessageText)) require.NoError(t, err) for _, tc := range []struct { name string diff --git a/cmd/docs.gen.go b/cmd/docs.gen.go index 1645b7fad7a..2c2e242c518 100644 --- a/cmd/docs.gen.go +++ b/cmd/docs.gen.go @@ -622,9 +622,8 @@ func init() { "\n" + "For more advanced usage, you can use the full power of the\n" + "[`text/template`](https://pkg.go.dev/text/template) language. chezmoi includes\n" + - "all of the hermetic text functions from\n" + - "[sprig](http://masterminds.github.io/sprig/) and its own [functions for\n" + - "interacting with password\n" + + "all of the text functions from [sprig](http://masterminds.github.io/sprig/) and\n" + + "its own [functions for interacting with password\n" + "managers](https://github.com/twpayne/chezmoi/blob/master/docs/REFERENCE.md#template-functions).\n" + "\n" + "Templates can be executed directly from the command line, without the need to\n" + @@ -2178,8 +2177,8 @@ func init() { "\n" + "## Template functions\n" + "\n" + - "All standard [`text/template`](https://pkg.go.dev/text/template) and [hermetic\n" + - "text template functions from `sprig`](http://masterminds.github.io/sprig/) are\n" + + "All standard [`text/template`](https://pkg.go.dev/text/template) and [text\n" + + "template functions from `sprig`](http://masterminds.github.io/sprig/) are\n" + "included. chezmoi provides some additional functions.\n" + "\n" + "### `bitwarden` [*args*]\n" + diff --git a/docs/HOWTO.md b/docs/HOWTO.md index 4d022190eb7..8ed76166625 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -177,9 +177,8 @@ For a full list of variables, run: For more advanced usage, you can use the full power of the [`text/template`](https://pkg.go.dev/text/template) language. chezmoi includes -all of the hermetic text functions from -[sprig](http://masterminds.github.io/sprig/) and its own [functions for -interacting with password +all of the text functions from [sprig](http://masterminds.github.io/sprig/) and +its own [functions for interacting with password managers](https://github.com/twpayne/chezmoi/blob/master/docs/REFERENCE.md#template-functions). Templates can be executed directly from the command line, without the need to diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 559d5099d8d..1efcbc1fc82 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -844,8 +844,8 @@ and/or digits. ## Template functions -All standard [`text/template`](https://pkg.go.dev/text/template) and [hermetic -text template functions from `sprig`](http://masterminds.github.io/sprig/) are +All standard [`text/template`](https://pkg.go.dev/text/template) and [text +template functions from `sprig`](http://masterminds.github.io/sprig/) are included. chezmoi provides some additional functions. ### `bitwarden` [*args*]