Skip to content

Remove trailing slash on drive path #697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ Contributors are:
-Alexis Horgix Chotard
-Piotr Babij <piotr.babij _at_ gmail.com>
-Mikuláš Poul <mikulaspoul _at_ gmail.com>
-Charles Bouchard-Légaré <cblegare.atl _at_ ntis.ca>

Portions derived from other open source works and are clearly marked.
2 changes: 1 addition & 1 deletion git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def _to_relative_path(cls, parent_repo, path):
if not path.startswith(working_tree_linux):
raise ValueError("Submodule checkout path '%s' needs to be within the parents repository at '%s'"
% (working_tree_linux, path))
path = path[len(working_tree_linux) + 1:]
path = path[len(working_tree_linux.rstrip('/')) + 1:]
if not path:
raise ValueError("Absolute submodule path '%s' didn't yield a valid relative path" % path)
# end verify converted relative path makes sense
Expand Down
12 changes: 11 additions & 1 deletion git/test/test_submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import git
from git.cmd import Git
from git.compat import string_types
from git.compat import string_types, is_win
from git.exc import (
InvalidGitRepositoryError,
RepositoryDirtyError
Expand Down Expand Up @@ -911,3 +911,13 @@ def test_branch_renames(self, rw_dir):
parent_repo.submodule_update(to_latest_revision=True, force_reset=True)
assert sm_mod.commit() == sm_pfb.commit, "Now head should have been reset"
assert sm_mod.head.ref.name == sm_pfb.name

@skipIf(not is_win, "Specifically for Windows.")
def test_to_relative_path_with_super_at_root_drive(self):
class Repo(object):
working_tree_dir = 'D:\\'
super_repo = Repo()
submodule_path = 'D:\\submodule_path'
relative_path = Submodule._to_relative_path(super_repo, submodule_path)
msg = '_to_relative_path should be "submodule_path" but was "%s"' % relative_path
assert relative_path == 'submodule_path', msg