Skip to content

Commit

Permalink
fix(shell): fix drive case for default Windows docker.path_mapping (#…
Browse files Browse the repository at this point in the history
…159)

Close #159
  • Loading branch information
Toilal committed Jan 14, 2021
1 parent f9e11a8 commit a3e2c09
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ddb/feature/docker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,22 @@ def _configure_defaults_debug(feature_config):

@staticmethod
def _configure_defaults_path_mapping(feature_config):
"""
On windows, this generates a default path mapping matching docker-compose behavior when
COMPOSE_CONVERT_WINDOWS_PATHS=1 is enabled.
Drive letter should be lowercased to have the same behavior
https://github.com/docker/compose/blob/f1059d75edf76e8856469108997c15bb46a41777/compose/config/types.py#L123-L132
"""
path_mapping = feature_config.get('path_mapping')
if path_mapping is None:
path_mapping = {}
if config.data.get('core.os') == 'nt':
raw = config.data.get('core.path.project_home')
mapped = re.sub(r"^([a-zA-Z]):", r"/\1", raw)
mapped = pathlib.Path(mapped).as_posix()
mapped = re.sub(r"(\/)(.)(\/.*)", lambda x: x.group(1) + x.group(2).lower() + x.group(3), mapped)
path_mapping[raw] = mapped
feature_config['path_mapping'] = path_mapping

Expand Down

0 comments on commit a3e2c09

Please sign in to comment.