From 57ba0edbd191e574ff390b9ada068616ccd6c80d Mon Sep 17 00:00:00 2001 From: Loren Gordon Date: Fri, 26 Aug 2016 17:50:05 -0400 Subject: [PATCH] Normalizes path for git and git submodules `_git_ls_files()` returns file paths with forward slashes. For files in submodules, add_prefix_to_each() is called to prefix all the submodule files with the relative path to the project root. On Windows, the relative path contains backslashes. Since not every file in the project is in a submodule, the combined list of files ended up with some files that use forward slashes and others that use backslashes. For project structures where the submodules share a path segment with the project source, this caused `add_directories()` to create duplicate directory entries in the list of files. The duplicate entries would result in a traceback with a WindowsError when `os.mkdir()` was called to create the same directory a second time. See #61 for more details. This commit replaces the backslashes with forward slashes in the relative path, eliminating the duplicate directory entries. --- check_manifest.py | 2 +- tests.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/check_manifest.py b/check_manifest.py index 948cd7c..364606b 100755 --- a/check_manifest.py +++ b/check_manifest.py @@ -302,7 +302,7 @@ def get_versioned_files(cls): files = cls._git_ls_files() submodules = cls._list_submodules() for subdir in submodules: - subdir = os.path.relpath(subdir) + subdir = os.path.relpath(subdir).replace(os.path.sep, '/') files += add_prefix_to_each(subdir, cls._git_ls_files(subdir)) return add_directories(files) diff --git a/tests.py b/tests.py index 4401936..ac454f0 100644 --- a/tests.py +++ b/tests.py @@ -952,7 +952,7 @@ def test_get_versioned_files_with_git_submodules(self): self.vcs._run('git', 'submodule', 'update', '--init', '--recursive') self.assertEqual( get_vcs_files(), - [fn.replace('/', os.path.sep) for fn in [ + [ '.gitmodules', 'file5', 'sub1', @@ -963,7 +963,7 @@ def test_get_versioned_files_with_git_submodules(self): 'sub2/file3', 'sub2/sub3', 'sub2/sub3/file4', - ]]) + ]) class BzrHelper(VCSHelper):