-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
379 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,29 @@ | ||
chezmoi cat $HOME${/}.bashrc | ||
stdout '# contents of .bashrc' | ||
cmp stdout ${CHEZMOISOURCEDIR}/dot_bashrc | ||
|
||
chezmoi cat $HOME${/}.gitconfig | ||
cmp stdout golden/.gitconfig | ||
|
||
chezmoi cat $HOME${/}.symlink | ||
stdout 'target' | ||
|
||
! chezmoi cat $HOME${/}.ssh | ||
stdout 'not a file or symlink' | ||
|
||
-- golden/.gitconfig -- | ||
[user] | ||
email = user@home.org | ||
-- home/user/.bashrc -- | ||
# contents of .bashrc | ||
-- home/user/.config/chezmoi/chezmoi.toml -- | ||
[data] | ||
email = "user@home.org" | ||
-- home/user/.local/share/chezmoi/dot_bashrc -- | ||
# contents of .bashrc | ||
-- home/user/.local/share/chezmoi/dot_gitconfig.tmpl -- | ||
[user] | ||
email = {{ .email }} | ||
-- home/user/.local/share/chezmoi/private_dot_ssh/config -- | ||
# contents of .ssh/config | ||
-- home/user/.local/share/chezmoi/symlink_dot_symlink -- | ||
target |
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,20 +1,20 @@ | ||
chezmoi chattr +empty $HOME${/}.bashrc | ||
exists ${CHEZMOISOURCEDIR}${/}empty_dot_bashrc | ||
exists ${CHEZMOISOURCEDIR}/empty_dot_bashrc | ||
|
||
chezmoi chattr +template $HOME${/}.bashrc | ||
exists ${CHEZMOISOURCEDIR}${/}empty_dot_bashrc.tmpl | ||
exists ${CHEZMOISOURCEDIR}/empty_dot_bashrc.tmpl | ||
|
||
chezmoi chattr +private $HOME${/}.bashrc | ||
exists ${CHEZMOISOURCEDIR}${/}private_empty_dot_bashrc.tmpl | ||
exists ${CHEZMOISOURCEDIR}/private_empty_dot_bashrc.tmpl | ||
|
||
chezmoi chattr noempty $HOME${/}.bashrc | ||
exists ${CHEZMOISOURCEDIR}${/}private_dot_bashrc.tmpl | ||
exists ${CHEZMOISOURCEDIR}/private_dot_bashrc.tmpl | ||
|
||
chezmoi chattr -- -template $HOME${/}.bashrc | ||
exists ${CHEZMOISOURCEDIR}${/}private_dot_bashrc | ||
exists ${CHEZMOISOURCEDIR}/private_dot_bashrc | ||
|
||
chezmoi chattr nop $HOME${/}.bashrc | ||
exists ${CHEZMOISOURCEDIR}${/}dot_bashrc | ||
exists ${CHEZMOISOURCEDIR}/dot_bashrc | ||
|
||
-- home/user/.local/share/chezmoi/dot_bashrc -- | ||
# contents of .bashrc |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
chezmoi completion bash | ||
stdout '# bash completion for chezmoi' | ||
|
||
chezmoi completion fish | ||
stdout '# fish completion for chezmoi' | ||
|
||
chezmoi completion zsh | ||
stdout '#compdef _chezmoi chezmoi' | ||
|
||
! chezmoi completion ksh | ||
stdout 'unsupported shell' |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
chezmoi data | ||
stdout '"chezmoi":' | ||
|
||
chezmoi data --format=json | ||
stdout '"chezmoi":' | ||
|
||
chezmoi data --format=toml | ||
stdout '[chezmoi]' | ||
|
||
chezmoi data --format=yaml | ||
stdout 'chezmoi:' |
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
chmod 700 $HOME/.ssh | ||
|
||
# test that chezmoi diff generates no output when the source and destination states are equal | ||
chezmoi diff | ||
! stdout . | ||
|
||
# test that chezmoi diff generates a diff when a file is added to the source state | ||
cp golden/dot_inputrc ${CHEZMOISOURCEDIR}/dot_inputrc | ||
chezmoi diff | ||
cmpenv stdout golden/add-file-diff | ||
rm ${CHEZMOISOURCEDIR}/dot_inputrc | ||
|
||
# test that chezmoi diff generates a diff when a file is edited | ||
edit $HOME/.bashrc | ||
chezmoi diff | ||
cmpenv stdout golden/modify-file-diff | ||
chezmoi apply | ||
|
||
# test that chezmoi diff generates a diff when a file is removed from the destination directory | ||
rm $HOME/.bashrc | ||
chezmoi diff | ||
cmpenv stdout golden/remove-file-diff | ||
chezmoi apply | ||
|
||
# test that chezmoi diff generates a diff when a directory is removed from the destination directory | ||
rm $HOME/.ssh | ||
chezmoi diff | ||
cmpenv stdout golden/remove-dir-diff | ||
chezmoi apply | ||
|
||
[windows] stop 'remaining tests use POSIX file modes' | ||
|
||
# test that chezmoi diff generates a diff when a file's permissions are changed | ||
chmod 755 $HOME/.bashrc | ||
chezmoi diff | ||
cmpenv stdout golden/chmod-file-diff | ||
chezmoi apply | ||
|
||
# test that chezmoi diff generates a diff when a dir's permissions are changed | ||
# FIXME show changes to permissions in diff | ||
chmod 755 $HOME/.ssh | ||
chezmoi diff | ||
cmpenv stdout golden/chmod-dir-diff | ||
chezmoi apply | ||
|
||
-- golden/add-file-diff -- | ||
install -m 644 /dev/null $WORK/home/user/.inputrc | ||
--- a$WORK/home/user/.inputrc | ||
+++ b$WORK/home/user/.inputrc | ||
@@ -0,0 +1,1 @@ | ||
+# contents of .inputrc | ||
-- golden/modify-file-diff -- | ||
install -m 644 /dev/null $WORK/home/user/.bashrc | ||
--- a$WORK/home/user/.bashrc | ||
+++ b$WORK/home/user/.bashrc | ||
@@ -1,2 +1,1 @@ | ||
# contents of .bashrc | ||
-# edited | ||
-- golden/remove-file-diff -- | ||
install -m 644 /dev/null $WORK/home/user/.bashrc | ||
--- a$WORK/home/user/.bashrc | ||
+++ b$WORK/home/user/.bashrc | ||
@@ -0,0 +1,1 @@ | ||
+# contents of .bashrc | ||
-- golden/remove-dir-diff -- | ||
mkdir -m 700 $WORK/home/user/.ssh | ||
install -m 644 /dev/null $WORK/home/user/.ssh/config | ||
--- a$WORK/home/user/.ssh/config | ||
+++ b$WORK/home/user/.ssh/config | ||
@@ -0,0 +1,1 @@ | ||
+# contents of .ssh/config | ||
-- golden/chmod-file-diff -- | ||
chmod 644 $WORK/home/user/.bashrc | ||
-- golden/chmod-dir-diff -- | ||
chmod 700 $WORK/home/user/.ssh | ||
-- golden/dot_inputrc -- | ||
# contents of .inputrc | ||
-- home/user/.bashrc -- | ||
# contents of .bashrc | ||
-- home/user/.ssh/config -- | ||
# contents of .ssh/config | ||
-- home/user/.local/share/chezmoi/dot_bashrc -- | ||
# contents of .bashrc | ||
-- home/user/.local/share/chezmoi/private_dot_ssh/config -- | ||
# contents of .ssh/config |
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 |
---|---|---|
@@ -0,0 +1,125 @@ | ||
chezmoi --format=json dump | ||
cmpenv stdout golden/dump.json | ||
|
||
chezmoi --format=json dump $HOME${/}.bashrc | ||
cmpenv stdout golden/dump-bashrc.json | ||
|
||
chezmoi --format=json dump $HOME${/}.ssh | ||
cmpenv stdout golden/dump-ssh.json | ||
|
||
chezmoi --format=json --recursive=false dump $HOME${/}.ssh | ||
cmpenv stdout golden/dump-ssh-non-recursive.json | ||
|
||
chezmoi --format=yaml dump | ||
cmpenv stdout golden/dump.yaml | ||
|
||
! chezmoi dump $HOME${/}.inputrc | ||
stdout 'file does not exist' | ||
|
||
-- golden/dump.json -- | ||
[ | ||
{ | ||
"type": "file", | ||
"sourcePath": "$WORK/home/user/.local/share/chezmoi/dot_bashrc", | ||
"targetPath": ".bashrc", | ||
"empty": false, | ||
"encrypted": false, | ||
"perm": 420, | ||
"template": false, | ||
"contents": "# contents of .bashrc\n" | ||
}, | ||
{ | ||
"type": "dir", | ||
"sourcePath": "$WORK/home/user/.local/share/chezmoi/private_dot_ssh", | ||
"targetPath": ".ssh", | ||
"exact": false, | ||
"perm": 448, | ||
"entries": [ | ||
{ | ||
"type": "file", | ||
"sourcePath": "$WORK/home/user/.local/share/chezmoi/private_dot_ssh/config", | ||
"targetPath": ".ssh/config", | ||
"empty": false, | ||
"encrypted": false, | ||
"perm": 420, | ||
"template": false, | ||
"contents": "# contents of .ssh/config\n" | ||
} | ||
] | ||
} | ||
] | ||
-- golden/dump-bashrc.json -- | ||
[ | ||
{ | ||
"type": "file", | ||
"sourcePath": "$WORK/home/user/.local/share/chezmoi/dot_bashrc", | ||
"targetPath": ".bashrc", | ||
"empty": false, | ||
"encrypted": false, | ||
"perm": 420, | ||
"template": false, | ||
"contents": "# contents of .bashrc\n" | ||
} | ||
] | ||
-- golden/dump-ssh.json -- | ||
[ | ||
{ | ||
"type": "dir", | ||
"sourcePath": "$WORK/home/user/.local/share/chezmoi/private_dot_ssh", | ||
"targetPath": ".ssh", | ||
"exact": false, | ||
"perm": 448, | ||
"entries": [ | ||
{ | ||
"type": "file", | ||
"sourcePath": "$WORK/home/user/.local/share/chezmoi/private_dot_ssh/config", | ||
"targetPath": ".ssh/config", | ||
"empty": false, | ||
"encrypted": false, | ||
"perm": 420, | ||
"template": false, | ||
"contents": "# contents of .ssh/config\n" | ||
} | ||
] | ||
} | ||
] | ||
-- golden/dump-ssh-non-recursive.json -- | ||
[ | ||
{ | ||
"type": "dir", | ||
"sourcePath": "$WORK/home/user/.local/share/chezmoi/private_dot_ssh", | ||
"targetPath": ".ssh", | ||
"exact": false, | ||
"perm": 448, | ||
"entries": null | ||
} | ||
] | ||
-- golden/dump.yaml -- | ||
- type: file | ||
sourcePath: $WORK/home/user/.local/share/chezmoi/dot_bashrc | ||
targetPath: .bashrc | ||
empty: false | ||
encrypted: false | ||
perm: 420 | ||
template: false | ||
contents: | | ||
# contents of .bashrc | ||
- type: dir | ||
sourcePath: $WORK/home/user/.local/share/chezmoi/private_dot_ssh | ||
targetPath: .ssh | ||
exact: false | ||
perm: 448 | ||
entries: | ||
- type: file | ||
sourcePath: $WORK/home/user/.local/share/chezmoi/private_dot_ssh/config | ||
targetPath: .ssh/config | ||
empty: false | ||
encrypted: false | ||
perm: 420 | ||
template: false | ||
contents: | | ||
# contents of .ssh/config | ||
-- home/user/.local/share/chezmoi/dot_bashrc -- | ||
# contents of .bashrc | ||
-- home/user/.local/share/chezmoi/private_dot_ssh/config -- | ||
# contents of .ssh/config |
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,17 +1,17 @@ | ||
edit ${CHEZMOISOURCEDIR}/dot_bashrc | ||
grep -count=1 '# edited' ${CHEZMOISOURCEDIR}${/}dot_bashrc | ||
grep -count=1 '# edited' ${CHEZMOISOURCEDIR}/dot_bashrc | ||
|
||
chezmoi apply | ||
grep -count=1 '# edited' $HOME${/}.bashrc | ||
grep -count=1 '# edited' $HOME/.bashrc | ||
|
||
edit ${CHEZMOISOURCEDIR}${/}dot_bashrc | ||
grep -count=2 '# edited' ${CHEZMOISOURCEDIR}${/}dot_bashrc | ||
edit ${CHEZMOISOURCEDIR}/dot_bashrc | ||
grep -count=2 '# edited' ${CHEZMOISOURCEDIR}/dot_bashrc | ||
|
||
chezmoi forget $HOME${/}.bashrc | ||
! exists ${CHEZMOISOURCEDIR}${/}dot_bashrc | ||
! exists ${CHEZMOISOURCEDIR}/dot_bashrc | ||
|
||
chezmoi apply | ||
grep -count=1 '# edited' $HOME${/}.bashrc | ||
grep -count=1 '# edited' $HOME/.bashrc | ||
|
||
-- home/user/.local/share/chezmoi/dot_bashrc -- | ||
# contents of .bashrc |
Oops, something went wrong.