Skip to content

Commit

Permalink
fix: Only set $CHEZMOI_VERBOSE when --verbose is set
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Mar 23, 2023
1 parent 4fef1fa commit ced12b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion pkg/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1918,11 +1918,13 @@ func (c *Config) persistentPreRunRootE(cmd *cobra.Command, args []string) error
"SOURCE_DIR": templateData.SourceDir.String(),
"UID": templateData.UID,
"USERNAME": templateData.Username,
"VERBOSE": strconv.FormatBool(c.Verbose),
"WORKING_TREE": templateData.WorkingTree.String(),
} {
scriptEnv = append(scriptEnv, "CHEZMOI_"+key+"="+value)
}
if c.Verbose {
scriptEnv = append(scriptEnv, "CHEZMOI_VERBOSE=1")
}
for groupKey, group := range map[string]map[string]any{
"KERNEL": templateData.Kernel,
"OS_RELEASE": templateData.OSRelease,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/testdata/scripts/scriptenv.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ stdout ^WORK=${WORK@R}$
[darwin] stdout ^CHEZMOI_OS=darwin$
[linux] stdout ^CHEZMOI_OS=linux$
stdout ^CHEZMOI_SOURCE_DIR=${CHEZMOISOURCEDIR@R}/home$
stdout ^CHEZMOI_VERBOSE=false$
stdout ^CHEZMOI_VERBOSE=$
stdout ^SCRIPTENV_KEY=SCRIPTENV_VALUE$

# test that chezmoi passes along --verbose in scripts
Expand All @@ -15,7 +15,7 @@ stdout ^WORK=${WORK@R}$
[darwin] stdout ^CHEZMOI_OS=darwin$
[linux] stdout ^CHEZMOI_OS=linux$
stdout ^CHEZMOI_SOURCE_DIR=${CHEZMOISOURCEDIR@R}/home$
stdout ^CHEZMOI_VERBOSE=true$
stdout ^CHEZMOI_VERBOSE=1$
stdout ^SCRIPTENV_KEY=SCRIPTENV_VALUE$

-- home/user/.config/chezmoi/chezmoi.toml --
Expand Down

0 comments on commit ced12b8

Please sign in to comment.