Give priority to CLASS by processing those patterns separately (#51)
This commit is contained in:
parent
297df5d231
commit
5678e383d8
1 changed files with 20 additions and 17 deletions
37
yadm
37
yadm
|
@ -116,7 +116,7 @@ function alt() {
|
||||||
|
|
||||||
match_class="$(config local.class)"
|
match_class="$(config local.class)"
|
||||||
if [ -z "$match_class" ] ; then
|
if [ -z "$match_class" ] ; then
|
||||||
match_class="()"
|
match_class="%"
|
||||||
fi
|
fi
|
||||||
match_class="(%|$match_class)"
|
match_class="(%|$match_class)"
|
||||||
|
|
||||||
|
@ -140,7 +140,8 @@ function alt() {
|
||||||
match_user="(%|$match_user)"
|
match_user="(%|$match_user)"
|
||||||
|
|
||||||
#; regex for matching "<file>##CLASS.SYSTEM.HOSTNAME.USER"
|
#; regex for matching "<file>##CLASS.SYSTEM.HOSTNAME.USER"
|
||||||
match="^(.+)##(()|$match_class|$match_system|$match_class\.$match_system|$match_system\.$match_host|$match_class\.$match_system\.$match_host|$match_system\.$match_host\.$match_user|$match_class\.$match_system\.$match_host\.$match_user)$"
|
match1="^(.+)##(()|$match_system|$match_system\.$match_host|$match_system\.$match_host\.$match_user)$"
|
||||||
|
match2="^(.+)##($match_class|$match_class\.$match_system|$match_class\.$match_system\.$match_host|$match_class\.$match_system\.$match_host\.$match_user)$"
|
||||||
|
|
||||||
#; process relative to YADM_WORK
|
#; process relative to YADM_WORK
|
||||||
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
||||||
|
@ -170,23 +171,25 @@ function alt() {
|
||||||
|
|
||||||
#; loop over all "tracked" files
|
#; loop over all "tracked" files
|
||||||
#; for every file which matches the above regex, create a symlink
|
#; for every file which matches the above regex, create a symlink
|
||||||
last_linked=''
|
for match in $match1 $match2; do
|
||||||
local IFS=$'\n'
|
last_linked=''
|
||||||
for tracked_file in $("$GIT_PROGRAM" ls-files | sort) "${ENC_FILES[@]}"; do
|
local IFS=$'\n'
|
||||||
tracked_file="$YADM_WORK/$tracked_file"
|
for tracked_file in $("$GIT_PROGRAM" ls-files | sort) "${ENC_FILES[@]}"; do
|
||||||
#; process both the path, and it's parent directory
|
tracked_file="$YADM_WORK/$tracked_file"
|
||||||
for alt_path in "$tracked_file" "${tracked_file%/*}"; do
|
#; process both the path, and it's parent directory
|
||||||
if [ -e "$alt_path" ] ; then
|
for alt_path in "$tracked_file" "${tracked_file%/*}"; do
|
||||||
if [[ $alt_path =~ $match ]] ; then
|
if [ -e "$alt_path" ] ; then
|
||||||
if [ "$alt_path" != "$last_linked" ] ; then
|
if [[ $alt_path =~ $match ]] ; then
|
||||||
new_link="${BASH_REMATCH[1]}"
|
if [ "$alt_path" != "$last_linked" ] ; then
|
||||||
debug "Linking $alt_path to $new_link"
|
new_link="${BASH_REMATCH[1]}"
|
||||||
[ -n "$loud" ] && echo "Linking $alt_path to $new_link"
|
debug "Linking $alt_path to $new_link"
|
||||||
ln -nfs "$alt_path" "$new_link"
|
[ -n "$loud" ] && echo "Linking $alt_path to $new_link"
|
||||||
last_linked="$alt_path"
|
ln -nfs "$alt_path" "$new_link"
|
||||||
|
last_linked="$alt_path"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue