File tree Expand file tree Collapse file tree 4 files changed +19
-4
lines changed Expand file tree Collapse file tree 4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ def test_bootstrap(
2222 paths .bootstrap .write (
2323 '#!/bin/bash\n '
2424 f'echo { expect } \n '
25+ f'[[ $(id -un) = $YADM_USER ]] && echo "user is set"\n '
2526 f'exit { code } \n '
2627 )
2728 paths .bootstrap .chmod (0o775 )
@@ -30,6 +31,7 @@ def test_bootstrap(
3031 if exists and executable :
3132 assert run .err == ''
3233 assert expect in run .out
34+ assert 'user is set' in run .out
3335 else :
3436 assert expect in run .err
3537 assert run .out == ''
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def test_set_alt_values(
2727 YADM_TEST=1 source { yadm } &&
2828 set_operating_system &&
2929 YADM_DIR={ paths .yadm } YADM_DATA={ paths .data } configure_paths &&
30- set_alt_values
30+ ALT_VALUES_SET=0 set_alt_values
3131 echo "class='$YADM_CLASS'"
3232 echo "os='$YADM_OS'"
3333 echo "host='$YADM_HOSTNAME'"
@@ -69,7 +69,7 @@ def test_distro(runner, yadm):
6969 YADM_TEST=1 source { yadm }
7070 function config() {{ echo "$1"; }}
7171 function query_distro() {{ echo "testdistro"; }}
72- set_alt_values
72+ ALT_VALUES_SET=0 set_alt_values
7373 echo "distro='$YADM_DISTRO'"
7474 """
7575 run = runner (command = ['bash' ], inp = script )
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ ENCRYPT_INCLUDE_FILES="unparsed"
6262
6363LEGACY_WARNING_ISSUED=0
6464INVALID_ALT=()
65+ ALT_VALUES_SET=" ${YADM_TEST:- 0} "
6566
6667GPG_OPTS=()
6768OPENSSL_OPTS=()
@@ -584,6 +585,9 @@ function remove_stale_links() {
584585
585586function set_alt_values() {
586587
588+ [[ $ALT_VALUES_SET = 1 ]] && return
589+ ALT_VALUES_SET=1
590+
587591 export YADM_CLASS
588592 export YADM_OS
589593 export YADM_HOSTNAME
@@ -680,6 +684,8 @@ function bootstrap() {
680684 # GIT_DIR should not be set for user's bootstrap code
681685 unset GIT_DIR
682686
687+ set_alt_values
688+
683689 echo " Executing $YADM_BOOTSTRAP "
684690 exec " $YADM_BOOTSTRAP "
685691
@@ -1784,6 +1790,8 @@ function invoke_hook() {
17841790 export -f unix_path
17851791 export -f mixed_path
17861792
1793+ set_alt_values
1794+
17871795 " $hook_command "
17881796 hook_status=$?
17891797
Original file line number Diff line number Diff line change @@ -112,7 +112,9 @@ to "false".
112112.B bootstrap
113113Execute
114114.I $HOME/.config/yadm/bootstrap
115- if it exists.
115+ if it exists. The variables that are set when processing Jinja or ESH templates
116+ (see the TEMPLATES section) are set in the environment (except for
117+ .IR YADM_SOURCE ).
116118.TP
117119.BI clone " url
118120Clone a remote repository for tracking dotfiles.
@@ -891,7 +893,10 @@ will never be run. This allows one to "short-circuit" any operation using a
891893.I pre_
892894hook.
893895
894- Hooks have the following environment variables available to them at runtime:
896+ Hooks have the following variables, plus the variables set when processing
897+ Jinja or ESH templates (see the TEMPLATES section), available to them as
898+ environment variables at runtime (except for
899+ .IR YADM_SOURCE ).
895900.TP
896901.B YADM_HOOK_COMMAND
897902The command which triggered the hook
You can’t perform that action at this time.
0 commit comments