mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-16 23:09:11 +00:00
fix and tests for #302
This commit is contained in:
@@ -47,6 +47,8 @@ $ cp <encrypted-version-of-secret> dotfiles/secret
|
|||||||
|
|
||||||
* commit and push the changes
|
* commit and push the changes
|
||||||
|
|
||||||
|
See [transformations](../config-details.md#entry-transformations).
|
||||||
|
|
||||||
## Load passphrase from file
|
## Load passphrase from file
|
||||||
|
|
||||||
Passphrase is retrieved using a script:
|
Passphrase is retrieved using a script:
|
||||||
@@ -64,3 +66,5 @@ variables:
|
|||||||
trans_read:
|
trans_read:
|
||||||
_gpg: "gpg2 --batch --yes --passphrase-file <(cat {{@@ gpg_password_file @@}}) -q --for-your-eyes-only --no-tty -d {0} > {1}"
|
_gpg: "gpg2 --batch --yes --passphrase-file <(cat {{@@ gpg_password_file @@}}) -q --for-your-eyes-only --no-tty -d {0} > {1}"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
See [transformations](../config-details.md#entry-transformations).
|
||||||
|
|||||||
@@ -245,6 +245,11 @@ def _dotfile_install(o, dotfile, tmpdir=None):
|
|||||||
if not tmp:
|
if not tmp:
|
||||||
return False, dotfile.key, None
|
return False, dotfile.key, None
|
||||||
src = tmp
|
src = tmp
|
||||||
|
# make sure to re-evaluate if is template
|
||||||
|
is_template = dotfile.template and Templategen.is_template(
|
||||||
|
src,
|
||||||
|
ignore=ignores,
|
||||||
|
)
|
||||||
r, err = inst.install(t, src, dotfile.dst,
|
r, err = inst.install(t, src, dotfile.dst,
|
||||||
LinkTypes.NOLINK,
|
LinkTypes.NOLINK,
|
||||||
actionexec=pre_actions_exec,
|
actionexec=pre_actions_exec,
|
||||||
|
|||||||
@@ -123,11 +123,13 @@ echo "{{@@ header() @@}}" > ${tmps}/dotfiles/fl
|
|||||||
|
|
||||||
# create the normal dotfile
|
# create the normal dotfile
|
||||||
echo "before" > ${tmps}/dotfiles/fn
|
echo "before" > ${tmps}/dotfiles/fn
|
||||||
echo "{#@@ should not be stripped @@#}" >> ${tmps}/dotfiles/fn
|
echo "{#@@ should be stripped @@#}" >> ${tmps}/dotfiles/fn
|
||||||
echo "after" >> ${tmps}/dotfiles/fn
|
echo "after" >> ${tmps}/dotfiles/fn
|
||||||
|
|
||||||
# install
|
# install
|
||||||
|
echo "installing"
|
||||||
cd ${ddpath} | ${bin} install -f --showdiff -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} install -f --showdiff -c ${cfg} -p p1 -V
|
||||||
|
echo "comparing"
|
||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -V
|
||||||
|
|
||||||
# simple file
|
# simple file
|
||||||
@@ -170,7 +172,7 @@ grep 'header' ${tmpd}/f1 || (echo "header stripped" && exit 1)
|
|||||||
# normal dotfile
|
# normal dotfile
|
||||||
echo "* normal dotfile"
|
echo "* normal dotfile"
|
||||||
[ ! -e ${tmpd}/fn ] && echo 'not installed' && exit 1
|
[ ! -e ${tmpd}/fn ] && echo 'not installed' && exit 1
|
||||||
grep 'should not be stripped' ${tmpd}/fn && echo "no templated" && exit 1
|
grep 'should be stripped' ${tmpd}/fn && echo "not templated" && exit 1
|
||||||
|
|
||||||
# test backup done
|
# test backup done
|
||||||
echo "before" > ${tmps}/dotfiles/f1
|
echo "before" > ${tmps}/dotfiles/f1
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ cat > ${cfg} << _EOF
|
|||||||
trans_read:
|
trans_read:
|
||||||
r_echo_abs_src: echo "\$(cat {0}); {{@@ _dotfile_abs_src @@}}" > {1}
|
r_echo_abs_src: echo "\$(cat {0}); {{@@ _dotfile_abs_src @@}}" > {1}
|
||||||
r_echo_var: echo "\$(cat {0}); {{@@ r_var @@}}" > {1}
|
r_echo_var: echo "\$(cat {0}); {{@@ r_var @@}}" > {1}
|
||||||
|
reverse_it: cat {0} | rev > {1}
|
||||||
trans_write:
|
trans_write:
|
||||||
w_echo_key: echo "\$(cat {0}); {{@@ _dotfile_key @@}}" > {1}
|
w_echo_key: echo "\$(cat {0}); {{@@ _dotfile_key @@}}" > {1}
|
||||||
w_echo_var: echo "\$(cat {0}); {{@@ w_var @@}}" > {1}
|
w_echo_var: echo "\$(cat {0}); {{@@ w_var @@}}" > {1}
|
||||||
@@ -85,12 +86,17 @@ dotfiles:
|
|||||||
src: ghi
|
src: ghi
|
||||||
trans_read: r_echo_var
|
trans_read: r_echo_var
|
||||||
trans_write: w_echo_var
|
trans_write: w_echo_var
|
||||||
|
f_rev:
|
||||||
|
dst: ${tmpd}/rev
|
||||||
|
src: rev
|
||||||
|
trans_read: reverse_it
|
||||||
profiles:
|
profiles:
|
||||||
p1:
|
p1:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
- f_def
|
- f_def
|
||||||
- f_ghi
|
- f_ghi
|
||||||
|
- f_rev
|
||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
@@ -98,6 +104,7 @@ _EOF
|
|||||||
echo 'abc' > ${tmps}/dotfiles/abc
|
echo 'abc' > ${tmps}/dotfiles/abc
|
||||||
echo 'marker' > ${tmps}/dotfiles/def
|
echo 'marker' > ${tmps}/dotfiles/def
|
||||||
echo 'ghi' > ${tmps}/dotfiles/ghi
|
echo 'ghi' > ${tmps}/dotfiles/ghi
|
||||||
|
echo '{{@@ profile @@}}' | rev > ${tmps}/dotfiles/rev
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# test install and compare
|
# test install and compare
|
||||||
@@ -110,11 +117,14 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V
|
|||||||
[ ! -e ${tmpd}/def ] && exit 1
|
[ ! -e ${tmpd}/def ] && exit 1
|
||||||
[ ! -e ${tmpd}/abc ] && exit 1
|
[ ! -e ${tmpd}/abc ] && exit 1
|
||||||
[ ! -e ${tmpd}/ghi ] && exit 1
|
[ ! -e ${tmpd}/ghi ] && exit 1
|
||||||
|
[ ! -e ${tmpd}/rev ] && exit 1
|
||||||
grep marker ${tmpd}/def
|
grep marker ${tmpd}/def
|
||||||
cat ${tmpd}/abc
|
cat ${tmpd}/abc
|
||||||
grep "^abc; ${tmps}/dotfiles/abc$" ${tmpd}/abc
|
grep "^abc; ${tmps}/dotfiles/abc$" ${tmpd}/abc
|
||||||
cat ${tmpd}/ghi
|
cat ${tmpd}/ghi
|
||||||
grep "^ghi; readvar$" ${tmpd}/ghi
|
grep "^ghi; readvar$" ${tmpd}/ghi
|
||||||
|
cat ${tmpd}/rev
|
||||||
|
grep "^p1$" ${tmpd}/rev
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# test update
|
# test update
|
||||||
@@ -127,6 +137,7 @@ cd ${ddpath} | ${bin} update -f -k -c ${cfg} -p p1 -b -V
|
|||||||
[ ! -e ${tmps}/dotfiles/def ] && exit 1
|
[ ! -e ${tmps}/dotfiles/def ] && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/abc ] && exit 1
|
[ ! -e ${tmps}/dotfiles/abc ] && exit 1
|
||||||
[ ! -e ${tmps}/dotfiles/ghi ] && exit 1
|
[ ! -e ${tmps}/dotfiles/ghi ] && exit 1
|
||||||
|
[ ! -e ${tmps}/dotfiles/rev ] && exit 1
|
||||||
grep marker ${tmps}/dotfiles/def
|
grep marker ${tmps}/dotfiles/def
|
||||||
cat ${tmps}/dotfiles/abc
|
cat ${tmps}/dotfiles/abc
|
||||||
grep "^abc; ${tmps}/dotfiles/abc; f_abc$" ${tmps}/dotfiles/abc
|
grep "^abc; ${tmps}/dotfiles/abc; f_abc$" ${tmps}/dotfiles/abc
|
||||||
|
|||||||
Reference in New Issue
Block a user