Skip to content

Commit

Permalink
Merge pull request twpayne#1134 from twpayne/fix-1133
Browse files Browse the repository at this point in the history
Fix import command when destination already exists
  • Loading branch information
twpayne committed Apr 4, 2021
2 parents 7bce9fa + 505ca6a commit a3f8895
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions internal/chezmoi/sourcerelpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (p SourceRelPath) Join(elems ...SourceRelPath) SourceRelPath {
}
return SourceRelPath{
relPath: p.relPath.Join(elemRelPaths...),
isDir: elems[len(elems)-1].isDir,
}
}

Expand Down
14 changes: 12 additions & 2 deletions testdata/scripts/import.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
[!exec:tar] skip 'tar not found in $PATH'

mkhomedir

# test that chezmoi import imports and archive
exec tar czf archive.tar.gz archive

# test that chezmoi import imports an archive
chezmoi import --strip-components=1 archive.tar.gz
cmp $CHEZMOISOURCEDIR/dot_dir/dot_file golden/dot_dir/dot_file
cmp $CHEZMOISOURCEDIR/dot_dir/dot_symlink golden/dot_dir/symlink_dot_symlink

# test that chezmoi import run a second time overwrites
chezmoi import --strip-components=1 --debug archive.tar.gz

# test chezmoi import --destination
chhome home2/user
chezmoi import --strip-components=1 --destination=$HOME${/}.subdir archive.tar.gz
cmp $CHEZMOISOURCEDIR/dot_subdir/dot_dir/dot_file golden/dot_dir/dot_file
cmp $CHEZMOISOURCEDIR/dot_subdir/dot_dir/dot_symlink golden/dot_dir/symlink_dot_symlink

-- archive/.dir/.file --
# contents of .dir/.file
-- archive/.dir/.symlink --
Expand All @@ -16,3 +25,4 @@ cmp $CHEZMOISOURCEDIR/dot_dir/dot_symlink golden/dot_dir/symlink_dot_symlink
# contents of .dir/.file
-- golden/dot_dir/symlink_dot_symlink --
.file
-- home2/user/.local/share/chezmoi/dot_subdir/.keep --

0 comments on commit a3f8895

Please sign in to comment.