File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -11,13 +11,13 @@ setup() {
1111 test_util.cd_test
1212
1313 git init
14- git config --local user.name test
15- git config --local user.email test@example.com
14+ GIT_CONFIG_VALUE_0= ' test@example.com '
15+ GIT_CONFIG_VALUE_1= ' test'
1616 printf ' %s\n' ' A' > tmpfile
1717 git add .
1818 git commit -m ' test: add data A'
19- git config --local user.name testagain
20- git config --local user.email testagain@example.com
19+ GIT_CONFIG_VALUE_0= ' testagain@example.com '
20+ GIT_CONFIG_VALUE_1= ' testagain'
2121 printf ' %s\n' ' B' > tmpfile
2222 git add .
2323 git commit -m ' test: add data B'
Original file line number Diff line number Diff line change @@ -24,3 +24,22 @@ test_util.setup_file() {
2424test_util.cd_test () {
2525 cd " $BATS_TEST_TMPDIR "
2626}
27+
28+ test_util.set_git_config_env () {
29+ local -a varkeys=()
30+ readarray -t varkeys <( POSIXLY_CORRECT=1 set)
31+ for line in " ${varkeys[@]} " ; do
32+ if [[ $line =~ ^(GIT_CONFIG_KEY| GIT_CONFIG_VALUE) ]]; then
33+ unset -v " ${line%% =* } "
34+ fi
35+ done
36+
37+ local -n configobj=" $1 "
38+ local idx=0
39+ for key in " ${! configobj[@]} " ; do
40+ export " GIT_CONFIG_KEY_$idx =$key "
41+ export " GIT_CONFIG_VALUE_$idx =${configobj[$key]} "
42+ (( idx += 1 ))
43+ done
44+ export GIT_CONFIG_COUNT=" ${# configobj[@]} "
45+ }
You can’t perform that action at this time.
0 commit comments