Merge branch 'qubidt/default-link-conditional'
This commit is contained in:
commit
b35462ab95
2 changed files with 24 additions and 4 deletions
|
@ -30,12 +30,10 @@ class Link(dotbot.Plugin):
|
||||||
relink = defaults.get('relink', False)
|
relink = defaults.get('relink', False)
|
||||||
create = defaults.get('create', False)
|
create = defaults.get('create', False)
|
||||||
use_glob = defaults.get('glob', False)
|
use_glob = defaults.get('glob', False)
|
||||||
|
test = defaults.get('if', None)
|
||||||
if isinstance(source, dict):
|
if isinstance(source, dict):
|
||||||
# extended config
|
# extended config
|
||||||
test = source.get('if')
|
test = source.get('if', test)
|
||||||
if test is not None and not self._test_success(test):
|
|
||||||
self._log.lowinfo('Skipping %s' % destination)
|
|
||||||
continue
|
|
||||||
relative = source.get('relative', relative)
|
relative = source.get('relative', relative)
|
||||||
force = source.get('force', force)
|
force = source.get('force', force)
|
||||||
relink = source.get('relink', relink)
|
relink = source.get('relink', relink)
|
||||||
|
@ -44,6 +42,9 @@ class Link(dotbot.Plugin):
|
||||||
path = self._default_source(destination, source.get('path'))
|
path = self._default_source(destination, source.get('path'))
|
||||||
else:
|
else:
|
||||||
path = self._default_source(destination, source)
|
path = self._default_source(destination, source)
|
||||||
|
if test is not None and not self._test_success(test):
|
||||||
|
self._log.lowinfo('Skipping %s' % destination)
|
||||||
|
continue
|
||||||
path = os.path.expandvars(os.path.expanduser(path))
|
path = os.path.expandvars(os.path.expanduser(path))
|
||||||
if use_glob:
|
if use_glob:
|
||||||
self._log.debug("Globbing with path: " + str(path))
|
self._log.debug("Globbing with path: " + str(path))
|
||||||
|
|
|
@ -30,3 +30,22 @@ grep "apple" ~/.f &&
|
||||||
grep "apple" ~/.h &&
|
grep "apple" ~/.h &&
|
||||||
! test -f ~/.i
|
! test -f ~/.i
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'run 2' '
|
||||||
|
run_dotbot <<EOF
|
||||||
|
- defaults:
|
||||||
|
link:
|
||||||
|
if: "false"
|
||||||
|
- link:
|
||||||
|
~/.j:
|
||||||
|
path: f
|
||||||
|
if: "true"
|
||||||
|
~/.k:
|
||||||
|
path: f
|
||||||
|
EOF
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'test 2' '
|
||||||
|
grep "apple" ~/.j &&
|
||||||
|
! test -f ~/.k
|
||||||
|
'
|
||||||
|
|
Loading…
Reference in a new issue