1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

Store class/os/host/user overrides in the local repo config

Overrides are meant to be local to each system, unlike other
configurations which are often added to a user's dotfiles repository.

With this change, the configurations change names:

  alt.class => local.class
  alt.os    => local.os
  alt.host  => local.host
  alt.user  => local.user
This commit is contained in:
Tim Byrne
2017-01-26 08:29:51 -06:00
parent 76d90db627
commit d28df86494
4 changed files with 105 additions and 20 deletions

View File

@@ -129,3 +129,74 @@ setup() {
return 1
fi
}
@test "Command 'config' (local read)" {
echo "
When 'config' command is provided,
and an attribute is provided
and the attribute is configured
and the attribute is local.*
Fetch the value from the repo config
Report the requested value
Exit with 0
"
#; write local attributes
build_repo
for loption in class os host user; do
GIT_DIR="$T_DIR_REPO" git config "local.$loption" "custom_$loption"
done
#; run config
for loption in class os host user; do
run "${T_YADM_Y[@]}" config "local.$loption"
#; validate status and output
[ $status -eq 0 ]
if [ "$output" != "custom_$loption" ]; then
echo "ERROR: Incorrect value returned. Expected 'custom_$loption', got '$output'"
return 1
fi
done
}
@test "Command 'config' (local write)" {
echo "
When 'config' command is provided,
and an attribute is provided
and a value is provided
and the attribute is local.*
Report no output
Write the value to the repo config
Exit with 0
"
build_repo
local expected
local linecount
expected="[local]\n"
linecount=1
for loption in class os host user; do
#; update expected
expected="$expected\t$loption = custom_$loption\n"
((linecount+=1))
#; write local attributes
run "${T_YADM_Y[@]}" config "local.$loption" "custom_$loption"
#; validate status and output
[ $status -eq 0 ]
[ "$output" = "" ]
done
#; validate data
local config
config=$(tail "-$linecount" "$T_DIR_REPO/config")
expected=$(echo -ne "$expected")
if [ "$config" != "$expected" ]; then
echo "ERROR: Config does not match expected"
echo -e "$config"
echo -e "EXPECTED:\n$expected"
return 1
fi
}

View File

@@ -290,13 +290,13 @@ function test_alt() {
echo "
When the command 'alt' is provided
and file matches only ##SYSTEM
after setting alt.os
after setting local.os
Report the linking
Verify correct file is linked
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.os custom_system
GIT_DIR="$T_DIR_REPO" git config local.os custom_system
test_alt 'override_system' 'false' ''
}
@@ -304,13 +304,13 @@ function test_alt() {
echo "
When the command 'alt' is provided
and file matches only ##SYSTEM.HOST
after setting alt.host
after setting local.host
Report the linking
Verify correct file is linked
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.host custom_host
GIT_DIR="$T_DIR_REPO" git config local.host custom_host
test_alt 'override_host' 'false' ''
}
@@ -318,12 +318,12 @@ function test_alt() {
echo "
When the command 'alt' is provided
and file matches only ##SYSTEM.HOST.USER
after setting alt.user
after setting local.user
Report the linking
Verify correct file is linked
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.user custom_user
GIT_DIR="$T_DIR_REPO" git config local.user custom_user
test_alt 'override_user' 'false' ''
}

View File

@@ -74,7 +74,7 @@ function test_alt() {
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.class set_class
GIT_DIR="$T_DIR_REPO" git config local.class set_class
for WILD_C in 'local' 'wild'; do
local c_base="wild-class-$WILD_C"
@@ -118,7 +118,7 @@ function test_alt() {
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.class set_class
GIT_DIR="$T_DIR_REPO" git config local.class set_class
for WILD_C in 'local' 'wild'; do
local c_base="wild-class-system-$WILD_C"
@@ -170,7 +170,7 @@ function test_alt() {
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.class set_class
GIT_DIR="$T_DIR_REPO" git config local.class set_class
for WILD_C in 'local' 'wild'; do
local c_base="wild-class-system-host-$WILD_C"
@@ -199,7 +199,7 @@ function test_alt() {
Exit with 0
"
git config --file="$T_YADM_CONFIG" alt.class set_class
GIT_DIR="$T_DIR_REPO" git config local.class set_class
for WILD_C in 'local' 'wild'; do
local c_base="wild-class-system-host-user-$WILD_C"