-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Make chezmoi edit with no args open working tree (#1455)
- Loading branch information
Showing
5 changed files
with
47 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,51 @@ | ||
mkhomedir | ||
mksourcedir | ||
|
||
# test that chezmoi edit edits a single file | ||
chezmoi edit $HOME${/}.file | ||
grep -count=1 '# edited' $CHEZMOISOURCEDIR/dot_file | ||
! grep '# edited' $HOME/.file | ||
|
||
# test that chezmoi edit --apply applies the edit. | ||
chezmoi edit --apply --force $HOME${/}.file | ||
grep -count=2 '# edited' $CHEZMOISOURCEDIR/dot_file | ||
grep -count=2 '# edited' $HOME/.file | ||
|
||
# test that chezmoi edit edits a symlink | ||
chezmoi edit $HOME${/}.symlink | ||
grep -count=1 '# edited' $CHEZMOISOURCEDIR/symlink_dot_symlink | ||
|
||
chezmoi edit -v $HOME${/}script | ||
# test that chezmoi edit edits a script | ||
chezmoi edit $HOME${/}script | ||
grep -count=1 '# edited' $CHEZMOISOURCEDIR/run_script | ||
|
||
# test that chezmoi edit edits a file and a symlink | ||
chezmoi edit $HOME${/}.file $HOME${/}.symlink | ||
grep -count=3 '# edited' $CHEZMOISOURCEDIR/dot_file | ||
grep -count=2 '# edited' $CHEZMOISOURCEDIR/symlink_dot_symlink | ||
|
||
# test that chezmoi edit edits the working tree | ||
chezmoi edit | ||
exists $CHEZMOISOURCEDIR/.edited | ||
|
||
[windows] stop 'remaining tests use file modes' | ||
# test that chezmoi edit edits a directory | ||
[!windows] chezmoi edit $HOME${/}.dir | ||
[!windows] exists $CHEZMOISOURCEDIR/dot_dir/.edited | ||
|
||
chezmoi edit $HOME${/}.dir | ||
exists $CHEZMOISOURCEDIR/dot_dir/.edited | ||
# test that chezmoi edit edits a file when the working tree and the source dir are different | ||
chhome home2/user | ||
chezmoi edit $HOME${/}.file | ||
grep -count=1 '# edited' $CHEZMOISOURCEDIR/home/dot_file | ||
|
||
# test that chezmoi edit edits the working tree when working tree and the source dir are different | ||
chezmoi edit | ||
exists $CHEZMOISOURCEDIR/.edited | ||
! exists $CHEZMOISOURCEDIR/home/.edited | ||
|
||
-- home/user/.local/share/chezmoi/run_script -- | ||
#!/bin/sh | ||
-- home2/user/.config/chezmoi/chezmoi.toml -- | ||
sourceDir = "~/.local/share/chezmoi/home" | ||
-- home2/user/.local/share/chezmoi/.git/.keep -- | ||
-- home2/user/.local/share/chezmoi/home/dot_file -- | ||
# contents of .file |