File tree 4 files changed +19
-4
lines changed
4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ def test_bootstrap(
22
22
paths .bootstrap .write (
23
23
'#!/bin/bash\n '
24
24
f'echo { expect } \n '
25
+ f'[[ $(id -un) = $YADM_USER ]] && echo "user is set"\n '
25
26
f'exit { code } \n '
26
27
)
27
28
paths .bootstrap .chmod (0o775 )
@@ -30,6 +31,7 @@ def test_bootstrap(
30
31
if exists and executable :
31
32
assert run .err == ''
32
33
assert expect in run .out
34
+ assert 'user is set' in run .out
33
35
else :
34
36
assert expect in run .err
35
37
assert run .out == ''
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def test_set_alt_values(
27
27
YADM_TEST=1 source { yadm } &&
28
28
set_operating_system &&
29
29
YADM_DIR={ paths .yadm } YADM_DATA={ paths .data } configure_paths &&
30
- set_alt_values
30
+ ALT_VALUES_SET=0 set_alt_values
31
31
echo "class='$YADM_CLASS'"
32
32
echo "os='$YADM_OS'"
33
33
echo "host='$YADM_HOSTNAME'"
@@ -69,7 +69,7 @@ def test_distro(runner, yadm):
69
69
YADM_TEST=1 source { yadm }
70
70
function config() {{ echo "$1"; }}
71
71
function query_distro() {{ echo "testdistro"; }}
72
- set_alt_values
72
+ ALT_VALUES_SET=0 set_alt_values
73
73
echo "distro='$YADM_DISTRO'"
74
74
"""
75
75
run = runner (command = ['bash' ], inp = script )
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ ENCRYPT_INCLUDE_FILES="unparsed"
62
62
63
63
LEGACY_WARNING_ISSUED=0
64
64
INVALID_ALT=()
65
+ ALT_VALUES_SET=" ${YADM_TEST:- 0} "
65
66
66
67
GPG_OPTS=()
67
68
OPENSSL_OPTS=()
@@ -584,6 +585,9 @@ function remove_stale_links() {
584
585
585
586
function set_alt_values() {
586
587
588
+ [[ $ALT_VALUES_SET = 1 ]] && return
589
+ ALT_VALUES_SET=1
590
+
587
591
export YADM_CLASS
588
592
export YADM_OS
589
593
export YADM_HOSTNAME
@@ -680,6 +684,8 @@ function bootstrap() {
680
684
# GIT_DIR should not be set for user's bootstrap code
681
685
unset GIT_DIR
682
686
687
+ set_alt_values
688
+
683
689
echo " Executing $YADM_BOOTSTRAP "
684
690
exec " $YADM_BOOTSTRAP "
685
691
@@ -1784,6 +1790,8 @@ function invoke_hook() {
1784
1790
export -f unix_path
1785
1791
export -f mixed_path
1786
1792
1793
+ set_alt_values
1794
+
1787
1795
" $hook_command "
1788
1796
hook_status=$?
1789
1797
Original file line number Diff line number Diff line change @@ -112,7 +112,9 @@ to "false".
112
112
.B bootstrap
113
113
Execute
114
114
.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 ).
116
118
.TP
117
119
.BI clone " url
118
120
Clone a remote repository for tracking dotfiles.
@@ -891,7 +893,10 @@ will never be run. This allows one to "short-circuit" any operation using a
891
893
.I pre_
892
894
hook.
893
895
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 ).
895
900
.TP
896
901
.B YADM_HOOK_COMMAND
897
902
The command which triggered the hook
You can’t perform that action at this time.
0 commit comments