1
0
Fork 0
mirror of synced 2024-12-22 06:01:07 -05:00

Merge branch 'etkeys/bugfix/fix-glob-dropping-leading-dot'

This commit is contained in:
Anish Athalye 2021-02-25 06:44:32 -05:00
commit de8793de99
4 changed files with 55 additions and 1 deletions

View file

@ -182,6 +182,12 @@ mapped to extended configuration dictionaries.
| `if` | Execute this in your `$SHELL` and only link if it is successful. |
| `ignore-missing` | Do not fail if the source is missing and create the link anyway (default: false) |
Dotbot uses [glob.glob](https://docs.python.org/3/library/glob.html#glob.glob)
to resolve glob paths. However, due to its design, using a glob path such as
`config/*` for example, will not match items that being with `.`. To
specifically capture items that being with `.`, you will need to use a path
like this: `config/.*`.
#### Example
```yaml

View file

@ -76,6 +76,8 @@ class Link(dotbot.Plugin):
else:
self._log.lowinfo("Globs from '" + path + "': " + str(glob_results))
glob_base = path[:glob_star_loc]
if glob_base.endswith('/.') or glob_base == '.':
glob_base = path[:glob_star_loc - 1]
for glob_full_item in glob_results:
glob_item = glob_full_item[len(glob_base):]
glob_link_destination = os.path.join(destination, glob_item)

View file

@ -1,4 +1,4 @@
test_description='link glob'
test_description='link glob multi star'
. '../test-lib.bash'
test_expect_success 'setup' '

View file

@ -45,3 +45,49 @@ grep "apple" ~/bin/a &&
grep "banana" ~/bin/b &&
grep "cherry" ~/bin/c
'
test_expect_success 'setup 3' '
rm -rf ~/bin &&
echo "dot_apple" > ${DOTFILES}/bin/.a &&
echo "dot_banana" > ${DOTFILES}/bin/.b &&
echo "dot_cherry" > ${DOTFILES}/bin/.c
'
test_expect_success 'run 3' '
run_dotbot -v <<EOF
- defaults:
link:
glob: true
create: true
- link:
~/bin/: bin/.*
EOF
'
test_expect_success 'test 3' '
grep "dot_apple" ~/bin/.a &&
grep "dot_banana" ~/bin/.b &&
grep "dot_cherry" ~/bin/.c
'
test_expect_success 'setup 4' '
rm -rf ~/bin &&
echo "dot_apple" > ${DOTFILES}/.a &&
echo "dot_banana" > ${DOTFILES}/.b &&
echo "dot_cherry" > ${DOTFILES}/.c
'
test_expect_success 'run 4' '
run_dotbot -v <<EOF
- link:
"~":
path: .*
glob: true
EOF
'
test_expect_success 'test 4' '
grep "dot_apple" ~/.a &&
grep "dot_banana" ~/.b &&
grep "dot_cherry" ~/.c
'