mirror of
1
0
Fork 0

Rename 'canonicalize-path' into 'canonicalize'

This parallels 'relative' (it's not 'relative-path'). The old
'canonicalize-path' is still supported for backward compatibility.
This commit is contained in:
Anish Athalye 2021-02-25 08:26:19 -05:00
parent 66489f7955
commit f15293b3d5
3 changed files with 22 additions and 4 deletions

View File

@ -177,7 +177,7 @@ mapped to extended configuration dictionaries.
| `relink` | Removes the old target if it's a symlink (default: false) | | `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) | | `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) | | `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) | | `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. | | `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) | | `ignore-missing` | Do not fail if the source is missing and create the link anyway (default: false) |

View File

@ -27,7 +27,8 @@ class Link(dotbot.Plugin):
for destination, source in links.items(): for destination, source in links.items():
destination = os.path.expandvars(destination) destination = os.path.expandvars(destination)
relative = defaults.get('relative', False) 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) force = defaults.get('force', False)
relink = defaults.get('relink', False) relink = defaults.get('relink', False)
create = defaults.get('create', False) create = defaults.get('create', False)
@ -39,7 +40,7 @@ class Link(dotbot.Plugin):
# extended config # extended config
test = source.get('if', test) test = source.get('if', test)
relative = source.get('relative', relative) 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) force = source.get('force', force)
relink = source.get('relink', relink) relink = source.get('relink', relink)
create = source.get('create', create) create = source.get('create', create)
@ -123,7 +124,7 @@ class Link(dotbot.Plugin):
return basename return basename
else: else:
return source return source
def _create_glob_results(self, path, exclude_paths): def _create_glob_results(self, path, exclude_paths):
self._log.debug("Globbing with path: " + str(path)) self._log.debug("Globbing with path: " + str(path))
base_include = glob.glob(path) base_include = glob.glob(path)

View File

@ -3,6 +3,7 @@ test_description='linking path canonicalization can be disabled'
test_expect_success 'setup' ' test_expect_success 'setup' '
echo "apple" > ${DOTFILES}/f && echo "apple" > ${DOTFILES}/f &&
echo "grape" > ${DOTFILES}/g &&
ln -s dotfiles dotfiles-symlink ln -s dotfiles dotfiles-symlink
' '
@ -21,3 +22,19 @@ ${DOTBOT_EXEC} -c ./dotfiles-symlink/${INSTALL_CONF}
test_expect_success 'test' ' test_expect_success 'test' '
[ "$(readlink ~/.f | cut -d/ -f5-)" = "dotfiles-symlink/f" ] [ "$(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" ]
'