Skip to content

Commit

Permalink
Rename 'canonicalize-path' into 'canonicalize'
Browse files Browse the repository at this point in the history
This parallels 'relative' (it's not 'relative-path'). The old
'canonicalize-path' is still supported for backward compatibility.
  • Loading branch information
anishathalye committed Feb 25, 2021
1 parent 66489f7 commit f15293b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ mapped to extended configuration dictionaries.
| `relink` | Removes the old target if it's a symlink (default: false) |
| `force` | Force removes the old target, file or folder, and forces a new link (default: false) |
| `relative` | Use a relative path to the source when creating the symlink (default: false, absolute links) |
| `canonicalize-path` | Resolve any symbolic links encountered in the source to symlink to the canonical path (default: true, real paths) |
| `canonicalize` | Resolve any symbolic links encountered in the source to symlink to the canonical path (default: true, real paths) |
| `glob` | Treat a `*` character as a wildcard, and perform link operations on all of those matches (default: false) |
| `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) |
Expand Down
7 changes: 4 additions & 3 deletions dotbot/plugins/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def _process_links(self, links):
for destination, source in links.items():
destination = os.path.expandvars(destination)
relative = defaults.get('relative', False)
canonical_path = defaults.get('canonicalize-path', True)
# support old "canonicalize-path" key for compatibility
canonical_path = defaults.get('canonicalize', defaults.get('canonicalize-path', True))
force = defaults.get('force', False)
relink = defaults.get('relink', False)
create = defaults.get('create', False)
Expand All @@ -39,7 +40,7 @@ def _process_links(self, links):
# extended config
test = source.get('if', test)
relative = source.get('relative', relative)
canonical_path = source.get('canonicalize-path', canonical_path)
canonical_path = source.get('canonicalize', source.get('canonicalize-path', canonical_path))
force = source.get('force', force)
relink = source.get('relink', relink)
create = source.get('create', create)
Expand Down Expand Up @@ -123,7 +124,7 @@ def _default_source(self, destination, source):
return basename
else:
return source

def _create_glob_results(self, path, exclude_paths):
self._log.debug("Globbing with path: " + str(path))
base_include = glob.glob(path)
Expand Down
17 changes: 17 additions & 0 deletions test/tests/link-no-canonicalize.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ test_description='linking path canonicalization can be disabled'

test_expect_success 'setup' '
echo "apple" > ${DOTFILES}/f &&
echo "grape" > ${DOTFILES}/g &&
ln -s dotfiles dotfiles-symlink
'

Expand All @@ -21,3 +22,19 @@ ${DOTBOT_EXEC} -c ./dotfiles-symlink/${INSTALL_CONF}
test_expect_success 'test' '
[ "$(readlink ~/.f | cut -d/ -f5-)" = "dotfiles-symlink/f" ]
'

test_expect_success 'run 2' '
cat > "${DOTFILES}/${INSTALL_CONF}" <<EOF
- defaults:
link:
canonicalize: false
- link:
~/.g:
path: g
EOF
${DOTBOT_EXEC} -c ./dotfiles-symlink/${INSTALL_CONF}
'

test_expect_success 'test' '
[ "$(readlink ~/.g | cut -d/ -f5-)" = "dotfiles-symlink/g" ]
'

0 comments on commit f15293b

Please sign in to comment.