Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package chezmoi for openSUSE:Factory checked 
in at 2023-06-13 16:09:28
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/chezmoi (Old)
 and      /work/SRC/openSUSE:Factory/.chezmoi.new.15902 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "chezmoi"

Tue Jun 13 16:09:28 2023 rev:26 rq:1092658 version:2.34.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/chezmoi/chezmoi.changes  2023-06-06 
19:56:42.478632881 +0200
+++ /work/SRC/openSUSE:Factory/.chezmoi.new.15902/chezmoi.changes       
2023-06-13 16:09:32.970899386 +0200
@@ -1,0 +2,6 @@
+Mon Jun 12 16:58:23 UTC 2023 - Filippo Bonazzi <filippo.bona...@suse.com>
+
+- Update to version 2.34.1:
+  * feat: Add git.commitMessageTemplate configuration variable
+
+-------------------------------------------------------------------

Old:
----
  chezmoi-2.34.0.obscpio

New:
----
  chezmoi-2.34.1.obscpio

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ chezmoi.spec ++++++
--- /var/tmp/diff_new_pack.3UJeCk/_old  2023-06-13 16:09:34.078905923 +0200
+++ /var/tmp/diff_new_pack.3UJeCk/_new  2023-06-13 16:09:34.082905946 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           chezmoi
-Version:        2.34.0
+Version:        2.34.1
 Release:        0
 Summary:        A multi-host manager for dotfiles
 License:        MIT

++++++ _service ++++++
--- /var/tmp/diff_new_pack.3UJeCk/_old  2023-06-13 16:09:34.114906135 +0200
+++ /var/tmp/diff_new_pack.3UJeCk/_new  2023-06-13 16:09:34.118906158 +0200
@@ -2,7 +2,7 @@
   <service name="obs_scm" mode="manual">
     <param name="scm">git</param>
     <param name="url">https://github.com/twpayne/chezmoi.git</param>
-    <param name="revision">v2.34.0</param>
+    <param name="revision">v2.34.1</param>
     <param name="versionformat">@PARENT_TAG@</param>
     <param name="versionrewrite-pattern">v(.*)</param>
   </service>

++++++ chezmoi-2.34.0.obscpio -> chezmoi-2.34.1.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/.github/workflows/main.yml 
new/chezmoi-2.34.1/.github/workflows/main.yml
--- old/chezmoi-2.34.0/.github/workflows/main.yml       2023-06-05 
00:19:01.000000000 +0200
+++ new/chezmoi-2.34.1/.github/workflows/main.yml       2023-06-10 
14:32:22.000000000 +0200
@@ -10,7 +10,7 @@
     - v*
 env:
   AGE_VERSION: 1.1.1
-  GO_VERSION: 1.20.4
+  GO_VERSION: 1.20.5
   GOFUMPT_VERSION: 0.4.0
   GOLANGCI_LINT_VERSION: 1.53.2
   GOVERSIONINFO_VERSION: 1.4.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/chezmoi-2.34.0/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml
 
new/chezmoi-2.34.1/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml
--- 
old/chezmoi-2.34.0/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml
    2023-06-05 00:19:01.000000000 +0200
+++ 
new/chezmoi-2.34.1/assets/chezmoi.io/docs/reference/configuration-file/variables.md.yaml
    2023-06-10 14:32:22.000000000 +0200
@@ -185,6 +185,9 @@
     command:
       default: '`git`'
       description: git CLI command
+    commitMessageTemplate:
+      type: 'string'
+      description: Commit message template
   gitHub:
     refreshPeriod:
       type: duration
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/chezmoi-2.34.0/assets/chezmoi.io/docs/user-guide/daily-operations.md 
new/chezmoi-2.34.1/assets/chezmoi.io/docs/user-guide/daily-operations.md
--- old/chezmoi-2.34.0/assets/chezmoi.io/docs/user-guide/daily-operations.md    
2023-06-05 00:19:01.000000000 +0200
+++ new/chezmoi-2.34.1/assets/chezmoi.io/docs/user-guide/daily-operations.md    
2023-06-10 14:32:22.000000000 +0200
@@ -70,6 +70,17 @@
 changes. If you only set `autoCommit` to true then changes will be committed 
but
 not pushed.
 
+By default, `autoCommit` will generate a commit message based on the files
+changed. You can override this by setting the `git.commitMessageTemplate`
+configuration variable. For example, to have chezmoi prompt you for a commit
+message each time, use:
+
+```toml title="~/.config/chezmoi/chezmoi.toml"
+[git]
+    autoCommit = true
+    commitMessageTemplate = "{{ promptString \"Commit message\" }}"
+```
+
 Be careful when using `autoPush`. If your dotfiles repo is public and you
 accidentally add a secret in plain text, that secret will be pushed to your
 public repo.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/assets/templates/templates.go 
new/chezmoi-2.34.1/assets/templates/templates.go
--- old/chezmoi-2.34.0/assets/templates/templates.go    2023-06-05 
00:19:01.000000000 +0200
+++ new/chezmoi-2.34.1/assets/templates/templates.go    2023-06-10 
14:32:22.000000000 +0200
@@ -1,10 +1,13 @@
 // Package templates contains chezmoi's templates.
 package templates
 
-import "embed"
+import _ "embed"
 
-// FS contains all templates.
-//
-//go:embed *.sh
-//go:embed *.tmpl
-var FS embed.FS
+//go:embed COMMIT_MESSAGE.tmpl
+var CommitMessageTmpl string
+
+//go:embed install.sh
+var InstallSH []byte
+
+//go:embed versioninfo.json.tmpl
+var VersionInfoJSON []byte
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/assets/templates/templates_test.go 
new/chezmoi-2.34.1/assets/templates/templates_test.go
--- old/chezmoi-2.34.0/assets/templates/templates_test.go       2023-06-05 
00:19:01.000000000 +0200
+++ new/chezmoi-2.34.1/assets/templates/templates_test.go       1970-01-01 
01:00:00.000000000 +0100
@@ -1,12 +0,0 @@
-package templates
-
-import (
-       "testing"
-
-       "github.com/alecthomas/assert/v2"
-)
-
-func TestFS(t *testing.T) {
-       _, err := FS.ReadFile("COMMIT_MESSAGE.tmpl")
-       assert.NoError(t, err)
-}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/go.mod new/chezmoi-2.34.1/go.mod
--- old/chezmoi-2.34.0/go.mod   2023-06-05 00:19:01.000000000 +0200
+++ new/chezmoi-2.34.1/go.mod   2023-06-10 14:32:22.000000000 +0200
@@ -136,6 +136,7 @@
        github.com/charmbracelet/bubbles v0.16.1 // 
https://github.com/charmbracelet/bubbletea/issues/737
        github.com/charmbracelet/bubbletea v0.24.0 // 
https://github.com/charmbracelet/bubbletea/issues/737
        github.com/charmbracelet/bubbletea v0.24.1 // 
https://github.com/charmbracelet/bubbletea/issues/737
+       github.com/charmbracelet/bubbletea v0.24.2 // 
https://github.com/charmbracelet/bubbletea/issues/737
        github.com/sergi/go-diff v1.2.0 // 
https://github.com/sergi/go-diff/issues/123
        github.com/sergi/go-diff v1.3.0
        github.com/sergi/go-diff v1.3.1 // 
https://github.com/twpayne/chezmoi/issues/2706
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/pkg/cmd/config.go 
new/chezmoi-2.34.1/pkg/cmd/config.go
--- old/chezmoi-2.34.0/pkg/cmd/config.go        2023-06-05 00:19:01.000000000 
+0200
+++ new/chezmoi-2.34.1/pkg/cmd/config.go        2023-06-10 14:32:22.000000000 
+0200
@@ -192,6 +192,9 @@
        unmanaged       unmanagedCmdConfig
        upgrade         upgradeCmdConfig
 
+       // Common configuration.
+       interactiveTemplateFuncs interactiveTemplateFuncsConfig
+
        // Version information.
        version     semver.Version
        versionInfo VersionInfo
@@ -735,12 +738,12 @@
        chezmoi.RecursiveMerge(funcMap, c.templateFuncs)
        initTemplateFuncs := map[string]any{
                "exit":             c.exitInitTemplateFunc,
-               "promptBool":       c.promptBoolInitTemplateFunc,
-               "promptBoolOnce":   c.promptBoolOnceInitTemplateFunc,
-               "promptInt":        c.promptIntInitTemplateFunc,
-               "promptIntOnce":    c.promptIntOnceInitTemplateFunc,
-               "promptString":     c.promptStringInitTemplateFunc,
-               "promptStringOnce": c.promptStringOnceInitTemplateFunc,
+               "promptBool":       c.promptBoolInteractiveTemplateFunc,
+               "promptBoolOnce":   c.promptBoolOnceInteractiveTemplateFunc,
+               "promptInt":        c.promptIntInteractiveTemplateFunc,
+               "promptIntOnce":    c.promptIntOnceInteractiveTemplateFunc,
+               "promptString":     c.promptStringInteractiveTemplateFunc,
+               "promptStringOnce": c.promptStringOnceInteractiveTemplateFunc,
                "stdinIsATTY":      c.stdinIsATTYInitTemplateFunc,
                "writeToStdout":    c.writeToStdout,
        }
@@ -1332,18 +1335,19 @@
        if status.Empty() {
                return nil
        }
-       commitMessageTemplate, err := 
templates.FS.ReadFile("COMMIT_MESSAGE.tmpl")
-       if err != nil {
-               return err
-       }
        funcMap := maps.Clone(sprig.TxtFuncMap())
-       funcMap["targetRelPath"] = func(source string) string {
-               return 
chezmoi.NewSourceRelPath(source).TargetRelPath(c.encryption.EncryptedSuffix()).String()
-       }
+       maps.Copy(funcMap, map[string]any{
+               "promptBool":   c.promptBoolInteractiveTemplateFunc,
+               "promptInt":    c.promptIntInteractiveTemplateFunc,
+               "promptString": c.promptStringInteractiveTemplateFunc,
+               "targetRelPath": func(source string) string {
+                       return 
chezmoi.NewSourceRelPath(source).TargetRelPath(c.encryption.EncryptedSuffix()).String()
+               },
+       })
        templateOptions := chezmoi.TemplateOptions{
                Options: append([]string(nil), c.Template.Options...),
        }
-       commitMessageTmpl, err := chezmoi.ParseTemplate("commit_message", 
commitMessageTemplate, funcMap, templateOptions)
+       commitMessageTmpl, err := chezmoi.ParseTemplate("commit_message", 
[]byte(c.Git.CommitMessageTemplate), funcMap, templateOptions) //nolint:lll
        if err != nil {
                return err
        }
@@ -2525,7 +2529,8 @@
                },
                Format: writeDataFormatJSON,
                Git: gitCmdConfig{
-                       Command: "git",
+                       Command:               "git",
+                       CommitMessageTemplate: templates.CommitMessageTmpl,
                },
                GitHub: gitHubConfig{
                        RefreshPeriod: 1 * time.Minute,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/pkg/cmd/generatecmd.go 
new/chezmoi-2.34.1/pkg/cmd/generatecmd.go
--- old/chezmoi-2.34.0/pkg/cmd/generatecmd.go   2023-06-05 00:19:01.000000000 
+0200
+++ new/chezmoi-2.34.1/pkg/cmd/generatecmd.go   2023-06-10 14:32:22.000000000 
+0200
@@ -31,11 +31,7 @@
        builder.Grow(16384)
        switch args[0] {
        case "install.sh":
-               data, err := templates.FS.ReadFile("install.sh")
-               if err != nil {
-                       return err
-               }
-               if _, err := builder.Write(data); err != nil {
+               if _, err := builder.Write(templates.InstallSH); err != nil {
                        return err
                }
        default:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/pkg/cmd/gitcmd.go 
new/chezmoi-2.34.1/pkg/cmd/gitcmd.go
--- old/chezmoi-2.34.0/pkg/cmd/gitcmd.go        2023-06-05 00:19:01.000000000 
+0200
+++ new/chezmoi-2.34.1/pkg/cmd/gitcmd.go        2023-06-10 14:32:22.000000000 
+0200
@@ -5,10 +5,11 @@
 )
 
 type gitCmdConfig struct {
-       Command    string `json:"command" mapstructure:"command" yaml:"command"`
-       AutoAdd    bool   `json:"autoadd" mapstructure:"autoadd" yaml:"autoadd"`
-       AutoCommit bool   `json:"autocommit" mapstructure:"autocommit" 
yaml:"autocommit"`
-       AutoPush   bool   `json:"autopush" mapstructure:"autopush" 
yaml:"autopush"`
+       Command               string `json:"command" mapstructure:"command" 
yaml:"command"`
+       AutoAdd               bool   `json:"autoadd" mapstructure:"autoadd" 
yaml:"autoadd"`
+       AutoCommit            bool   `json:"autocommit" 
mapstructure:"autocommit" yaml:"autocommit"`
+       AutoPush              bool   `json:"autopush" mapstructure:"autopush" 
yaml:"autopush"`
+       CommitMessageTemplate string `json:"commitMessageTemplate" 
mapstructure:"commitMessageTemplate" yaml:"commitMessageTemplate"` //nolint:lll
 }
 
 func (c *Config) newGitCmd() *cobra.Command {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/pkg/cmd/initcmd.go 
new/chezmoi-2.34.1/pkg/cmd/initcmd.go
--- old/chezmoi-2.34.0/pkg/cmd/initcmd.go       2023-06-05 00:19:01.000000000 
+0200
+++ new/chezmoi-2.34.1/pkg/cmd/initcmd.go       2023-06-10 14:32:22.000000000 
+0200
@@ -26,10 +26,6 @@
        filter            *chezmoi.EntryTypeFilter
        guessRepoURL      bool
        oneShot           bool
-       forcePromptOnce   bool
-       promptBool        map[string]string
-       promptInt         map[string]int
-       promptString      map[string]string
        purge             bool
        purgeBinary       bool
        recurseSubmodules bool
@@ -105,19 +101,16 @@
        }
 
        flags := initCmd.Flags()
+       c.addInteractiveTemplateFuncFlags(flags)
        flags.BoolVarP(&c.init.apply, "apply", "a", c.init.apply, "Update 
destination directory")
        flags.StringVar(&c.init.branch, "branch", c.init.branch, "Set initial 
branch to checkout")
        flags.VarP(&c.init.configPath, "config-path", "C", "Path to write 
generated config file")
        flags.BoolVar(&c.init.data, "data", c.init.data, "Include existing 
template data")
        flags.IntVarP(&c.init.depth, "depth", "d", c.init.depth, "Create a 
shallow clone")
        flags.VarP(c.init.filter.Exclude, "exclude", "x", "Exclude entry types")
-       flags.BoolVar(&c.init.forcePromptOnce, "prompt", 
c.init.forcePromptOnce, "Force prompt*Once template functions to prompt") 
//nolint:lll
        flags.BoolVarP(&c.init.guessRepoURL, "guess-repo-url", "g", 
c.init.guessRepoURL, "Guess the repo URL")
        flags.VarP(c.init.filter.Include, "include", "i", "Include entry types")
        flags.BoolVar(&c.init.oneShot, "one-shot", c.init.oneShot, "Run in 
one-shot mode")
-       flags.StringToStringVar(&c.init.promptBool, "promptBool", 
c.init.promptBool, "Populate promptBool")
-       flags.StringToIntVar(&c.init.promptInt, "promptInt", c.init.promptInt, 
"Populate promptInt")
-       flags.StringToStringVar(&c.init.promptString, "promptString", 
c.init.promptString, "Populate promptString")
        flags.BoolVarP(&c.init.purge, "purge", "p", c.init.purge, "Purge config 
and source directories after running")
        flags.BoolVarP(&c.init.purgeBinary, "purge-binary", "P", 
c.init.purgeBinary, "Purge chezmoi binary after running")
        flags.BoolVar(&c.init.recurseSubmodules, "recurse-submodules", 
c.init.recurseSubmodules, "Checkout submodules recursively") //nolint:lll
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/pkg/cmd/inittemplatefuncs.go 
new/chezmoi-2.34.1/pkg/cmd/inittemplatefuncs.go
--- old/chezmoi-2.34.0/pkg/cmd/inittemplatefuncs.go     2023-06-05 
00:19:01.000000000 +0200
+++ new/chezmoi-2.34.1/pkg/cmd/inittemplatefuncs.go     2023-06-10 
14:32:22.000000000 +0200
@@ -1,7 +1,6 @@
 package cmd
 
 import (
-       "fmt"
        "os"
 
        "golang.org/x/term"
@@ -13,129 +12,6 @@
        panic(chezmoi.ExitCodeError(code))
 }
 
-func (c *Config) promptBoolInitTemplateFunc(prompt string, args ...bool) bool {
-       if len(args) > 1 {
-               err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
-               panic(err)
-       }
-
-       if valueStr, ok := c.init.promptBool[prompt]; ok {
-               value, err := chezmoi.ParseBool(valueStr)
-               if err != nil {
-                       panic(err)
-               }
-               return value
-       }
-
-       value, err := c.promptBool(prompt, args...)
-       if err != nil {
-               panic(err)
-       }
-       return value
-}
-
-func (c *Config) promptBoolOnceInitTemplateFunc(m map[string]any, path any, 
prompt string, args ...bool) bool {
-       if len(args) > 1 {
-               err := fmt.Errorf("want 2 or 3 arguments, got %d", len(args)+2)
-               panic(err)
-       }
-
-       nestedMap, lastKey, err := nestedMapAtPath(m, path)
-       if err != nil {
-               panic(err)
-       }
-       if !c.init.forcePromptOnce {
-               if value, ok := nestedMap[lastKey]; ok {
-                       switch value := value.(type) {
-                       case bool:
-                               return value
-                       case string:
-                               if boolValue, err := chezmoi.ParseBool(value); 
err == nil {
-                                       return boolValue
-                               }
-                       }
-               }
-       }
-
-       return c.promptBoolInitTemplateFunc(prompt, args...)
-}
-
-func (c *Config) promptIntInitTemplateFunc(prompt string, args ...int64) int64 
{
-       if len(args) > 1 {
-               err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
-               panic(err)
-       }
-
-       if value, ok := c.init.promptInt[prompt]; ok {
-               return int64(value)
-       }
-
-       value, err := c.promptInt(prompt, args...)
-       if err != nil {
-               panic(err)
-       }
-       return value
-}
-
-func (c *Config) promptIntOnceInitTemplateFunc(m map[string]any, path any, 
prompt string, args ...int64) int64 {
-       if len(args) > 1 {
-               err := fmt.Errorf("want 2 or 3 arguments, got %d", len(args)+2)
-               panic(err)
-       }
-
-       nestedMap, lastKey, err := nestedMapAtPath(m, path)
-       if err != nil {
-               panic(err)
-       }
-       if !c.init.forcePromptOnce {
-               if value, ok := nestedMap[lastKey]; ok {
-                       if intValue, ok := value.(int64); ok {
-                               return intValue
-                       }
-               }
-       }
-
-       return c.promptIntInitTemplateFunc(prompt, args...)
-}
-
-func (c *Config) promptStringInitTemplateFunc(prompt string, args ...string) 
string {
-       if len(args) > 1 {
-               err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
-               panic(err)
-       }
-
-       if value, ok := c.init.promptString[prompt]; ok {
-               return value
-       }
-
-       value, err := c.promptString(prompt, args...)
-       if err != nil {
-               panic(err)
-       }
-       return value
-}
-
-func (c *Config) promptStringOnceInitTemplateFunc(m map[string]any, path any, 
prompt string, args ...string) string {
-       if len(args) > 1 {
-               err := fmt.Errorf("want 2 or 3 arguments, got %d", len(args)+2)
-               panic(err)
-       }
-
-       nestedMap, lastKey, err := nestedMapAtPath(m, path)
-       if err != nil {
-               panic(err)
-       }
-       if !c.init.forcePromptOnce {
-               if value, ok := nestedMap[lastKey]; ok {
-                       if stringValue, ok := value.(string); ok {
-                               return stringValue
-                       }
-               }
-       }
-
-       return c.promptStringInitTemplateFunc(prompt, args...)
-}
-
 func (c *Config) stdinIsATTYInitTemplateFunc() bool {
        file, ok := c.stdin.(*os.File)
        if !ok {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/pkg/cmd/inittemplatefuncs_test.go 
new/chezmoi-2.34.1/pkg/cmd/inittemplatefuncs_test.go
--- old/chezmoi-2.34.0/pkg/cmd/inittemplatefuncs_test.go        2023-06-05 
00:19:01.000000000 +0200
+++ new/chezmoi-2.34.1/pkg/cmd/inittemplatefuncs_test.go        2023-06-10 
14:32:22.000000000 +0200
@@ -7,7 +7,7 @@
        "github.com/alecthomas/assert/v2"
 )
 
-func TestPromptBoolInitTemplateFunc(t *testing.T) {
+func TestPromptBoolInteractiveTemplateFunc(t *testing.T) {
        for _, tc := range []struct {
                name              string
                prompt            string
@@ -70,17 +70,17 @@
                        assert.NoError(t, err)
                        if tc.expectedErr {
                                assert.Panics(t, func() {
-                                       
config.promptBoolInitTemplateFunc(tc.prompt, tc.args...)
+                                       
config.promptBoolInteractiveTemplateFunc(tc.prompt, tc.args...)
                                })
                        } else {
-                               assert.Equal(t, tc.expected, 
config.promptBoolInitTemplateFunc(tc.prompt, tc.args...))
+                               assert.Equal(t, tc.expected, 
config.promptBoolInteractiveTemplateFunc(tc.prompt, tc.args...))
                                assert.Equal(t, tc.expectedStdoutStr, 
stdout.String())
                        }
                })
        }
 }
 
-func TestPromptIntInitTemplateFunc(t *testing.T) {
+func TestPromptIntInteractiveTemplateFunc(t *testing.T) {
        for _, tc := range []struct {
                name              string
                prompt            string
@@ -143,17 +143,17 @@
                        assert.NoError(t, err)
                        if tc.expectedErr {
                                assert.Panics(t, func() {
-                                       
config.promptIntInitTemplateFunc(tc.prompt, tc.args...)
+                                       
config.promptIntInteractiveTemplateFunc(tc.prompt, tc.args...)
                                })
                        } else {
-                               assert.Equal(t, tc.expected, 
config.promptIntInitTemplateFunc(tc.prompt, tc.args...))
+                               assert.Equal(t, tc.expected, 
config.promptIntInteractiveTemplateFunc(tc.prompt, tc.args...))
                                assert.Equal(t, tc.expectedStdoutStr, 
stdout.String())
                        }
                })
        }
 }
 
-func TestPromptStringInitTemplateFunc(t *testing.T) {
+func TestPromptStringInteractiveTemplateFunc(t *testing.T) {
        for _, tc := range []struct {
                name              string
                prompt            string
@@ -229,10 +229,10 @@
                        assert.NoError(t, err)
                        if tc.expectedErr {
                                assert.Panics(t, func() {
-                                       
config.promptStringInitTemplateFunc(tc.prompt, tc.args...)
+                                       
config.promptStringInteractiveTemplateFunc(tc.prompt, tc.args...)
                                })
                        } else {
-                               assert.Equal(t, tc.expected, 
config.promptStringInitTemplateFunc(tc.prompt, tc.args...))
+                               assert.Equal(t, tc.expected, 
config.promptStringInteractiveTemplateFunc(tc.prompt, tc.args...))
                                assert.Equal(t, tc.expectedStdoutStr, 
stdout.String())
                        }
                })
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chezmoi-2.34.0/pkg/cmd/interactivetemplatefuncs.go 
new/chezmoi-2.34.1/pkg/cmd/interactivetemplatefuncs.go
--- old/chezmoi-2.34.0/pkg/cmd/interactivetemplatefuncs.go      1970-01-01 
01:00:00.000000000 +0100
+++ new/chezmoi-2.34.1/pkg/cmd/interactivetemplatefuncs.go      2023-06-10 
14:32:22.000000000 +0200
@@ -0,0 +1,146 @@
+package cmd
+
+import (
+       "fmt"
+
+       "github.com/spf13/pflag"
+
+       "github.com/twpayne/chezmoi/v2/pkg/chezmoi"
+)
+
+type interactiveTemplateFuncsConfig struct {
+       forcePromptOnce bool
+       promptBool      map[string]string
+       promptInt       map[string]int
+       promptString    map[string]string
+}
+
+func (c *Config) addInteractiveTemplateFuncFlags(flags *pflag.FlagSet) {
+       flags.BoolVar(&c.interactiveTemplateFuncs.forcePromptOnce, "prompt", 
c.interactiveTemplateFuncs.forcePromptOnce, "Force prompt*Once template 
functions to prompt") //nolint:lll
+       flags.StringToStringVar(&c.interactiveTemplateFuncs.promptBool, 
"promptBool", c.interactiveTemplateFuncs.promptBool, "Populate promptBool")     
                   //nolint:lll
+       flags.StringToIntVar(&c.interactiveTemplateFuncs.promptInt, 
"promptInt", c.interactiveTemplateFuncs.promptInt, "Populate promptInt")        
                       //nolint:lll
+       flags.StringToStringVar(&c.interactiveTemplateFuncs.promptString, 
"promptString", c.interactiveTemplateFuncs.promptString, "Populate 
promptString")                //nolint:lll
+}
+
+func (c *Config) promptBoolInteractiveTemplateFunc(prompt string, args 
...bool) bool {
+       if len(args) > 1 {
+               err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
+               panic(err)
+       }
+
+       if valueStr, ok := c.interactiveTemplateFuncs.promptBool[prompt]; ok {
+               value, err := chezmoi.ParseBool(valueStr)
+               if err != nil {
+                       panic(err)
+               }
+               return value
+       }
+
+       value, err := c.promptBool(prompt, args...)
+       if err != nil {
+               panic(err)
+       }
+       return value
+}
+
+func (c *Config) promptBoolOnceInteractiveTemplateFunc(m map[string]any, path 
any, prompt string, args ...bool) bool {
+       if len(args) > 1 {
+               err := fmt.Errorf("want 2 or 3 arguments, got %d", len(args)+2)
+               panic(err)
+       }
+
+       nestedMap, lastKey, err := nestedMapAtPath(m, path)
+       if err != nil {
+               panic(err)
+       }
+       if !c.interactiveTemplateFuncs.forcePromptOnce {
+               if value, ok := nestedMap[lastKey]; ok {
+                       switch value := value.(type) {
+                       case bool:
+                               return value
+                       case string:
+                               if boolValue, err := chezmoi.ParseBool(value); 
err == nil {
+                                       return boolValue
+                               }
+                       }
+               }
+       }
+
+       return c.promptBoolInteractiveTemplateFunc(prompt, args...)
+}
+
+func (c *Config) promptIntInteractiveTemplateFunc(prompt string, args 
...int64) int64 {
+       if len(args) > 1 {
+               err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
+               panic(err)
+       }
+
+       if value, ok := c.interactiveTemplateFuncs.promptInt[prompt]; ok {
+               return int64(value)
+       }
+
+       value, err := c.promptInt(prompt, args...)
+       if err != nil {
+               panic(err)
+       }
+       return value
+}
+
+func (c *Config) promptIntOnceInteractiveTemplateFunc(m map[string]any, path 
any, prompt string, args ...int64) int64 {
+       if len(args) > 1 {
+               err := fmt.Errorf("want 2 or 3 arguments, got %d", len(args)+2)
+               panic(err)
+       }
+
+       nestedMap, lastKey, err := nestedMapAtPath(m, path)
+       if err != nil {
+               panic(err)
+       }
+       if !c.interactiveTemplateFuncs.forcePromptOnce {
+               if value, ok := nestedMap[lastKey]; ok {
+                       if intValue, ok := value.(int64); ok {
+                               return intValue
+                       }
+               }
+       }
+
+       return c.promptIntInteractiveTemplateFunc(prompt, args...)
+}
+
+func (c *Config) promptStringInteractiveTemplateFunc(prompt string, args 
...string) string {
+       if len(args) > 1 {
+               err := fmt.Errorf("want 1 or 2 arguments, got %d", len(args)+1)
+               panic(err)
+       }
+
+       if value, ok := c.interactiveTemplateFuncs.promptString[prompt]; ok {
+               return value
+       }
+
+       value, err := c.promptString(prompt, args...)
+       if err != nil {
+               panic(err)
+       }
+       return value
+}
+
+func (c *Config) promptStringOnceInteractiveTemplateFunc(m map[string]any, 
path any, prompt string, args ...string) string { //nolint:lll
+       if len(args) > 1 {
+               err := fmt.Errorf("want 2 or 3 arguments, got %d", len(args)+2)
+               panic(err)
+       }
+
+       nestedMap, lastKey, err := nestedMapAtPath(m, path)
+       if err != nil {
+               panic(err)
+       }
+       if !c.interactiveTemplateFuncs.forcePromptOnce {
+               if value, ok := nestedMap[lastKey]; ok {
+                       if stringValue, ok := value.(string); ok {
+                               return stringValue
+                       }
+               }
+       }
+
+       return c.promptStringInteractiveTemplateFunc(prompt, args...)
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/chezmoi-2.34.0/pkg/cmd/testdata/scripts/autocommit.txtar 
new/chezmoi-2.34.1/pkg/cmd/testdata/scripts/autocommit.txtar
--- old/chezmoi-2.34.0/pkg/cmd/testdata/scripts/autocommit.txtar        
2023-06-05 00:19:01.000000000 +0200
+++ new/chezmoi-2.34.1/pkg/cmd/testdata/scripts/autocommit.txtar        
2023-06-10 14:32:22.000000000 +0200
@@ -36,6 +36,12 @@
 exec git --git-dir=$CHEZMOISOURCEDIR/.git show HEAD
 stdout 'Remove \.file'
 
+# test that chezmoi edit uses a custom commit message template
+appendline $CHEZMOICONFIGDIR/chezmoi.toml '    commitMessageTemplate = "feat: 
my commit"'
+exec chezmoi edit $HOME${/}.dir${/}file
+exec git --git-dir=$CHEZMOISOURCEDIR/.git show HEAD
+stdout 'feat: my commit'
+
 -- home/user/.config/chezmoi/chezmoi.toml --
 [git]
     autoCommit = true

++++++ chezmoi.obsinfo ++++++
--- /var/tmp/diff_new_pack.3UJeCk/_old  2023-06-13 16:09:34.514908495 +0200
+++ /var/tmp/diff_new_pack.3UJeCk/_new  2023-06-13 16:09:34.518908518 +0200
@@ -1,5 +1,5 @@
 name: chezmoi
-version: 2.34.0
-mtime: 1685917141
-commit: 006230cc05fc1fe017c942758ee92aee3058d9c5
+version: 2.34.1
+mtime: 1686400342
+commit: 38846a481d93ea762c599144956b45c86305f47e
 

++++++ vendor.tar.gz ++++++
/work/SRC/openSUSE:Factory/chezmoi/vendor.tar.gz 
/work/SRC/openSUSE:Factory/.chezmoi.new.15902/vendor.tar.gz differ: char 5, 
line 1

Reply via email to