Skip to content

Commit

Permalink
fix: Prevent chezmoi add from adding chezmoi's own executable
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jul 2, 2024
1 parent 2808e7c commit 2a75540
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/cmd/addcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"io/fs"
"os"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -177,6 +178,11 @@ func (c *Config) runAddCmd(cmd *cobra.Command, args []string, sourceState *chezm
return err
}

executable, err := os.Executable()
if err != nil {
return err
}

return sourceState.Add(
c.sourceSystem,
c.persistentState,
Expand All @@ -199,6 +205,7 @@ func (c *Config) runAddCmd(cmd *cobra.Command, args []string, sourceState *chezm
c.getConfigFileAbsPath().Dir(),
persistentStateFileAbsPath,
c.sourceDirAbsPath,
chezmoi.NewAbsPath(executable),
},
ReplaceFunc: c.defaultReplaceFunc,
Template: c.Add.template,
Expand Down

0 comments on commit 2a75540

Please sign in to comment.