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 @@ -63,6 +63,7 @@ ENCRYPT_INCLUDE_FILES="unparsed"
6363
6464LEGACY_WARNING_ISSUED=0
6565INVALID_ALT=()
66+ ALT_VALUES_SET=" ${YADM_TEST:- 0} "
6667
6768GPG_OPTS=()
6869OPENSSL_OPTS=()
@@ -596,6 +597,9 @@ function remove_stale_links() {
596597
597598function set_alt_values() {
598599
600+ [[ $ALT_VALUES_SET = 1 ]] && return
601+ ALT_VALUES_SET=1
602+
599603 export YADM_CLASS
600604 export YADM_ARCH
601605 export YADM_OS
@@ -698,6 +702,8 @@ function bootstrap() {
698702 # GIT_DIR should not be set for user's bootstrap code
699703 unset GIT_DIR
700704
705+ set_alt_values
706+
701707 echo " Executing $YADM_BOOTSTRAP "
702708 exec " $YADM_BOOTSTRAP "
703709
@@ -1770,6 +1776,8 @@ function invoke_hook() {
17701776 export -f unix_path
17711777 export -f mixed_path
17721778
1779+ set_alt_values
1780+
17731781 " $hook_command "
17741782 hook_status=$?
17751783
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.
@@ -876,7 +878,10 @@ will never be run. This allows one to "short-circuit" any operation using a
876878.I pre_
877879hook.
878880
879- Hooks have the following environment variables available to them at runtime:
881+ Hooks have the following variables, plus the variables set when processing
882+ Jinja or ESH templates (see the TEMPLATES section), available to them as
883+ environment variables at runtime (except for
884+ .IR YADM_SOURCE ).
880885.TP
881886.B YADM_HOOK_COMMAND
882887The command which triggered the hook
You can’t perform that action at this time.
0 commit comments