Skip to content

Commit

Permalink
fix: Ignore commands when creating archives
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Sep 15, 2022
1 parent 2abddec commit 80576f5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/chezmoi/tarwritersystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"archive/tar"
"io"
"io/fs"
"os/exec"
)

// A TarWriterSystem is a System that writes to a tar archive.
Expand Down Expand Up @@ -36,6 +37,11 @@ func (s *TarWriterSystem) Mkdir(name AbsPath, perm fs.FileMode) error {
return s.tarWriter.WriteHeader(&header)
}

// RunCmd implements System.RunCmd.
func (s *TarWriterSystem) RunCmd(cmd *exec.Cmd) error {
return nil
}

// RunScript implements System.RunScript.
func (s *TarWriterSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, interpreter *Interpreter) error {
return s.WriteFile(NewAbsPath(scriptname.String()), data, 0o700)
Expand Down
6 changes: 6 additions & 0 deletions pkg/chezmoi/zipwritersystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"archive/zip"
"io"
"io/fs"
"os/exec"
"time"
)

Expand Down Expand Up @@ -40,6 +41,11 @@ func (s *ZIPWriterSystem) Mkdir(name AbsPath, perm fs.FileMode) error {
return err
}

// RunCmd implements System.RunCmd.
func (s *ZIPWriterSystem) RunCmd(cmd *exec.Cmd) error {
return nil
}

// RunScript implements System.RunScript.
func (s *ZIPWriterSystem) RunScript(scriptname RelPath, dir AbsPath, data []byte, interpreter *Interpreter) error {
return s.WriteFile(NewAbsPath(scriptname.String()), data, 0o700)
Expand Down
6 changes: 6 additions & 0 deletions pkg/cmd/testdata/scripts/externalgitrepo.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ cd $WORK
exec chezmoi apply
cmp $HOME/.dir/.file golden/.file

# test that chezmoi archive --format=tar creates an archive
exec chezmoi archive --format=tar

# test that chezmoi archive --format=zip creates an archive
exec chezmoi archive --format=zip

chhome home2/user
mkgitconfig
expandenv $WORK/home2/user/.local/share/chezmoi/.chezmoiexternal.toml
Expand Down

0 comments on commit 80576f5

Please sign in to comment.