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

Commitae2b596

Browse files
committed
Made sure dry-run is properly implemented in Submodule.remove()
The root-submodule test is still failing though, this time even earlierthan before
1 parentc7b16ad commitae2b596

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

‎git/objects/submodule/base.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def move(self, module_path, configuration=True, module=True):
672672
returnself
673673

674674
@unbare_repo
675-
defremove(self,module=True,force=False,configuration=True,dry_run=False):
675+
defremove(self,module=True,force=False,configuration=True,dry_run=False,_is_recursive=False):
676676
"""Remove this submodule from the repository. This will remove our entry
677677
from the .gitmodules file and the entry in the .git/config file.
678678
@@ -705,7 +705,7 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False):
705705

706706
# Recursively remove children of this submodule
707707
forcsminself.children():
708-
csm.remove(module,force,configuration,dry_run)
708+
csm.remove(module,force,configuration,dry_run,_is_recursive=True)
709709
del(csm)
710710
# end
711711

@@ -772,7 +772,7 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False):
772772
# END delete tree if possible
773773
# END handle force
774774

775-
ifos.path.isdir(git_dir):
775+
ifnotdry_runandos.path.isdir(git_dir):
776776
rmtree(git_dir)
777777
# end handle separate bare repository
778778
# END handle module deletion
@@ -781,22 +781,28 @@ def remove(self, module=True, force=False, configuration=True, dry_run=False):
781781
######################
782782
ifconfigurationandnotdry_run:
783783
# first the index-entry
784-
index=self.repo.index
784+
parent_index=self.repo.index
785785
try:
786-
del(index.entries[index.entry_key(self.path,0)])
786+
del(parent_index.entries[parent_index.entry_key(self.path,0)])
787787
exceptKeyError:
788788
pass
789789
# END delete entry
790-
index.write()
790+
parent_index.write()
791791

792792
# now git config - need the config intact, otherwise we can't query
793-
#inforamtion anymore
793+
#information anymore
794794
writer=self.repo.config_writer()
795795
writer.remove_section(sm_section(self.name))
796796
writer.release()
797797
writer=self.config_writer()
798798
writer.remove_section()
799799
writer.release()
800+
801+
# Assure we don't leave the parent repository in a dirty state, and commit our changes
802+
# It's important for recursive, unforced, deletions to work as expected
803+
if_is_recursive:
804+
self.module().index.commit("Removed submodule '%s'"%self.name)
805+
# end
800806
# END delete configuration
801807

802808
# void our data not to delay invalid access

‎git/test/test_submodule.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,12 @@ def test_git_submodule_compatibility(self, rwdir):
666666

667667
# remove
668668
sm_module_path=sm.module().git_dir
669-
sm.remove()
670-
assertnotsm.exists()
671-
assertnotsm.module_exists()
672-
assertnotos.path.isdir(sm_module_path)
669+
670+
fordry_runin (True,False):
671+
sm.remove(dry_run=dry_run)
672+
assertsm.exists()==dry_run
673+
assertsm.module_exists()==dry_run
674+
assertos.path.isdir(sm_module_path)==dry_run
675+
# end for each dry-run mode
673676

674677

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp