1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 14:31:46 +00:00

fix and tests for #302

This commit is contained in:
deadc0de6
2021-02-17 13:40:55 +01:00
parent 58435ece94
commit f4ab927c9b
4 changed files with 24 additions and 2 deletions

View File

@@ -47,6 +47,8 @@ $ cp <encrypted-version-of-secret> dotfiles/secret
* commit and push the changes
See [transformations](../config-details.md#entry-transformations).
## Load passphrase from file
Passphrase is retrieved using a script:
@@ -64,3 +66,5 @@ variables:
trans_read:
_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).

View File

@@ -245,6 +245,11 @@ def _dotfile_install(o, dotfile, tmpdir=None):
if not tmp:
return False, dotfile.key, None
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,
LinkTypes.NOLINK,
actionexec=pre_actions_exec,

View File

@@ -123,11 +123,13 @@ echo "{{@@ header() @@}}" > ${tmps}/dotfiles/fl
# create the normal dotfile
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
# install
echo "installing"
cd ${ddpath} | ${bin} install -f --showdiff -c ${cfg} -p p1 -V
echo "comparing"
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -V
# simple file
@@ -170,7 +172,7 @@ grep 'header' ${tmpd}/f1 || (echo "header stripped" && exit 1)
# normal dotfile
echo "* normal dotfile"
[ ! -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
echo "before" > ${tmps}/dotfiles/f1

View File

@@ -61,6 +61,7 @@ cat > ${cfg} << _EOF
trans_read:
r_echo_abs_src: echo "\$(cat {0}); {{@@ _dotfile_abs_src @@}}" > {1}
r_echo_var: echo "\$(cat {0}); {{@@ r_var @@}}" > {1}
reverse_it: cat {0} | rev > {1}
trans_write:
w_echo_key: echo "\$(cat {0}); {{@@ _dotfile_key @@}}" > {1}
w_echo_var: echo "\$(cat {0}); {{@@ w_var @@}}" > {1}
@@ -85,12 +86,17 @@ dotfiles:
src: ghi
trans_read: r_echo_var
trans_write: w_echo_var
f_rev:
dst: ${tmpd}/rev
src: rev
trans_read: reverse_it
profiles:
p1:
dotfiles:
- f_abc
- f_def
- f_ghi
- f_rev
_EOF
#cat ${cfg}
@@ -98,6 +104,7 @@ _EOF
echo 'abc' > ${tmps}/dotfiles/abc
echo 'marker' > ${tmps}/dotfiles/def
echo 'ghi' > ${tmps}/dotfiles/ghi
echo '{{@@ profile @@}}' | rev > ${tmps}/dotfiles/rev
###########################
# 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}/abc ] && exit 1
[ ! -e ${tmpd}/ghi ] && exit 1
[ ! -e ${tmpd}/rev ] && exit 1
grep marker ${tmpd}/def
cat ${tmpd}/abc
grep "^abc; ${tmps}/dotfiles/abc$" ${tmpd}/abc
cat ${tmpd}/ghi
grep "^ghi; readvar$" ${tmpd}/ghi
cat ${tmpd}/rev
grep "^p1$" ${tmpd}/rev
###########################
# 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/abc ] && exit 1
[ ! -e ${tmps}/dotfiles/ghi ] && exit 1
[ ! -e ${tmps}/dotfiles/rev ] && exit 1
grep marker ${tmps}/dotfiles/def
cat ${tmps}/dotfiles/abc
grep "^abc; ${tmps}/dotfiles/abc; f_abc$" ${tmps}/dotfiles/abc