Support custom classes for alt-links (#21)

Class can be set using `yadm config alt.class <class>`
This commit is contained in:
Tim Byrne 2017-01-20 00:14:10 -06:00
parent d7abc7ff41
commit ce4ed41f10
No known key found for this signature in database
GPG Key ID: 6CBE24C2FD8CF76E
1 changed files with 8 additions and 2 deletions

10
yadm
View File

@ -108,6 +108,12 @@ function alt() {
require_repo
match_class="$(config alt.class)"
if [ -z "$match_class" ] ; then
match_class="()"
fi
match_class="(%|$match_class)"
match_system="$(config alt.os)"
if [ -z "$match_system" ] ; then
match_system=$(uname -s)
@ -127,8 +133,8 @@ function alt() {
fi
match_user="(%|$match_user)"
#; regex for matching "<file>##SYSTEM.HOSTNAME.USER"
match="^(.+)##($match_system|$match_system\.$match_host|$match_system\.$match_host\.$match_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)$"
#; process relative to YADM_WORK
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")