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

Commit7dd6186

Browse files
committed
test_submodule: fixed failures that arose due to changes of the original submodule names. Also, a major bug was fixed that cased submodules to always being updated recursively when using the RootModule.update method
submodule: previously, it would update the repository configuration during add(), but in fact it must be done during update() when the module is cloned, which is how the git-submodule implementation works
1 parent45c0f28 commit7dd6186

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

‎lib/git/objects/submodule/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,6 @@ def add(cls, repo, name, path, url=None, branch=None, no_checkout=False):
261261
# END handle path
262262
del(writer)
263263

264-
# NOTE: Have to write the repo config file as well, otherwise
265-
# the default implementation will be offended and not update the repository
266-
# Maybe this is a good way to assure it doesn't get into our way, but
267-
# we want to stay backwards compatible too ... . Its so redundant !
268-
repo.config_writer().set_value(sm_section(sm.name),'url',url)
269-
270264
# we deliberatly assume that our head matches our index !
271265
pcommit=repo.head.commit
272266
sm._parent_commit=pcommit
@@ -350,6 +344,12 @@ def update(self, recursive=False, init=True, to_latest_revision=False):
350344
exceptIndexError:
351345
print>>sys.stderr,"Warning: Failed to checkout tracking branch %s"%self.branch
352346
#END handle tracking branch
347+
348+
# NOTE: Have to write the repo config file as well, otherwise
349+
# the default implementation will be offended and not update the repository
350+
# Maybe this is a good way to assure it doesn't get into our way, but
351+
# we want to stay backwards compatible too ... . Its so redundant !
352+
self.repo.config_writer().set_value(sm_section(self.name),'url',self.url)
353353
#END handle initalization
354354

355355

‎lib/git/objects/submodule/root.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def update(self, previous_commit=None, recursive=True, force_remove=False, init=
244244
######################################
245245
forsminsms:
246246
# update the submodule using the default method
247-
sm.update(recursive=True,init=init,to_latest_revision=to_latest_revision)
247+
sm.update(recursive=False,init=init,to_latest_revision=to_latest_revision)
248248

249249
# update recursively depth first - question is which inconsitent
250250
# state will be better in case it fails somewhere. Defective branch

‎test/git/test_repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ def test_submodules(self):
560560
assertlen(self.rorepo.submodules)==1# non-recursive
561561
assertlen(list(self.rorepo.iter_submodules()))==2
562562

563-
assertisinstance(self.rorepo.submodule("lib/git/ext/gitdb"),Submodule)
563+
assertisinstance(self.rorepo.submodule("gitdb"),Submodule)
564564
self.failUnlessRaises(ValueError,self.rorepo.submodule,"doesn't exist")
565565

566566
@with_rw_repo('HEAD',bare=False)

‎test/git/test_submodule.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
classTestSubmodule(TestBase):
1414

15-
k_subm_current="00ce31ad308ff4c7ef874d2fa64374f47980c85c"
15+
k_subm_current="45c0f285a6d9d9214f8167742d12af2855f527fb"
1616
k_subm_changed="394ed7006ee5dc8bddfd132b64001d5dfc0ffdd3"
1717
k_no_subm_tag="0.1.6"
1818

@@ -33,7 +33,7 @@ def _do_base_tests(self, rwrepo):
3333
assertlen(Submodule.list_items(rwrepo,self.k_no_subm_tag))==0
3434

3535
assertsm.path=='lib/git/ext/gitdb'
36-
assertsm.path==sm.name#for now, this is True
36+
assertsm.path!=sm.name#in our case, we have ids there, which don't equal the path
3737
assertsm.url=='git://gitorious.org/git-python/gitdb.git'
3838
assertsm.branch.name=='master'# its unset in this case
3939
assertsm.parent_commit==rwrepo.head.commit
@@ -43,7 +43,7 @@ def _do_base_tests(self, rwrepo):
4343
# some commits earlier we still have a submodule, but its at a different commit
4444
smold=Submodule.iter_items(rwrepo,self.k_subm_changed).next()
4545
assertsmold.binsha!=sm.binsha
46-
assertsmold==sm# the nameis still the same
46+
assertsmold!=sm# the namechanged
4747

4848
# force it to reread its information
4949
del(smold._url)
@@ -71,12 +71,11 @@ def _do_base_tests(self, rwrepo):
7171
self.failUnlessRaises(ValueError,smold.config_writer)
7272
# END handle bare repo
7373

74-
# make the old into a new
74+
# make the old into a new - this doesn't work as the name changed
7575
prev_parent_commit=smold.parent_commit
76-
assertsmold.set_parent_commit(self.k_subm_current)issmold
77-
assertsmold.parent_commit!=prev_parent_commit
78-
assertsmold.binsha==sm.binsha
79-
smold.set_parent_commit(prev_parent_commit)
76+
self.failUnlessRaises(ValueError,smold.set_parent_commit,self.k_subm_current)
77+
# the sha is properly updated
78+
smold.set_parent_commit(self.k_subm_changed+"~1")
8079
assertsmold.binsha!=sm.binsha
8180

8281
# raises if the sm didn't exist in new parent - it keeps its
@@ -181,6 +180,10 @@ def _do_base_tests(self, rwrepo):
181180
csm.module().head.ref.set_tracking_branch(None)
182181
sm.update(recursive=True,to_latest_revision=True)
183182

183+
# to_latest_revision changes the child submodule's commit, it needs an
184+
# update now
185+
csm.set_parent_commit(csm.repo.head.commit)
186+
184187
# undo the changes
185188
sm.module().head.ref=smref
186189
csm.module().head.ref.set_tracking_branch(csm_tracking_branch)
@@ -191,8 +194,8 @@ def _do_base_tests(self, rwrepo):
191194
self.failUnlessRaises(ValueError,csm.remove,module=False,configuration=False)
192195
# We have modified the configuration, hence the index is dirty, and the
193196
# deletion will fail
194-
# NOTE: As we did a few updates in the meanwhile, the indiceswhere reset
195-
# Hence werestore some changes
197+
# NOTE: As we did a few updates in the meanwhile, the indiceswere reset
198+
# Hence wecreate some changes
196199
sm.config_writer().set_value("somekey","somevalue")
197200
csm.config_writer().set_value("okey","ovalue")
198201
self.failUnlessRaises(InvalidGitRepositoryError,sm.remove)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp