Skip to content

Commit

Permalink
Normalizes path for git and git submodules
Browse files Browse the repository at this point in the history
`_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 mgedmin#61 for more details.

This commit replaces the backslashes with forward slashes in the
relative path, eliminating the duplicate directory entries.
  • Loading branch information
lorengordon committed Aug 26, 2016
1 parent 2a40aa8 commit 57ba0ed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion check_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -963,7 +963,7 @@ def test_get_versioned_files_with_git_submodules(self):
'sub2/file3',
'sub2/sub3',
'sub2/sub3/file4',
]])
])


class BzrHelper(VCSHelper):
Expand Down

0 comments on commit 57ba0ed

Please sign in to comment.