Add runCommand function to Go template syntax

This makes it possible to use date and time in initial values like this:

```yaml
initialValue: 'ruudk/{{ runCommand "date +\"%Y/%-m\"" }}/'
```

I want to use this to configure my BranchPrefix like this:

```yaml
git:
  branchPrefix: 'ruudk/{{ runCommand "date +\"%Y/%-m\"" }}/'
```
This commit is contained in:
Ruud Kamphuis 2025-03-31 15:21:44 +02:00 committed by Stefan Haller
parent c7feba9bb1
commit 12820481e6
8 changed files with 140 additions and 3 deletions

View file

@ -246,7 +246,8 @@ func (self *HandlerCreator) getResolveTemplateFn(form map[string]string, promptR
}
funcs := template.FuncMap{
"quote": self.c.OS().Quote,
"quote": self.c.OS().Quote,
"runCommand": self.c.Git().Custom.TemplateFunctionRunCommand,
}
return func(templateStr string) (string, error) { return utils.ResolveTemplate(templateStr, objects, funcs) }