Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaaa8434

Browse files
committed
Submodule.move() will auto-rename the submodule if the name was equal to the path
Fixesgitpython-developers#238
1 parent20863cf commitaaa8434

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

‎git/objects/submodule/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ def move(self, module_path, configuration=True, module=True):
675675

676676
# rename the index entry - have to manipulate the index directly as
677677
# git-mv cannot be used on submodules ... yeah
678+
previous_sm_path=self.path
678679
try:
679680
ifconfiguration:
680681
try:
@@ -701,6 +702,11 @@ def move(self, module_path, configuration=True, module=True):
701702
raise
702703
# END handle undo rename
703704

705+
# Auto-rename submodule if it's name was 'default', that is, the checkout directory
706+
ifprevious_sm_path==self.name:
707+
self.rename(module_checkout_path)
708+
# end
709+
704710
returnself
705711

706712
@unbare_repo

‎git/test/test_submodule.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,12 +707,15 @@ def test_git_submodule_compatibility(self, rwdir):
707707
deftest_rename(self,rwdir):
708708
parent=git.Repo.init(os.path.join(rwdir,'parent'))
709709
sm_name='mymodules/myname'
710-
sm=parent.create_submodule(sm_name,'submodules/intermediate/one',url=self._submodule_url())
710+
sm=parent.create_submodule(sm_name,sm_name,url=self._submodule_url())
711711
parent.index.commit("Added submodule")
712712
assertsm._parent_commitisnotNone
713713

714714
assertsm.rename(sm_name)issmandsm.name==sm_name
715715

716+
new_path='renamed/myname'
717+
assertsm.move(new_path).name==new_path
718+
716719
new_sm_name="shortname"
717720
assertsm.rename(new_sm_name)issm
718721
assertsm.exists()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp