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

Commita0acb22

Browse files
committed
tests(submodule): add new submodule commits
It's somewhat more complex to add new commits in submodules to theparent repository. The new test shows how to do that in a 'GitPythonic'way.Related togitpython-developers#335
1 parentb2e4134 commita0acb22

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

‎git/test/test_submodule.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ def test_add_empty_repo(self, rwdir):
661661
# end for each checkout mode
662662

663663
@with_rw_directory
664-
deftest_git_submodules(self,rwdir):
664+
deftest_git_submodules_and_add_sm_with_new_commit(self,rwdir):
665665
parent=git.Repo.init(os.path.join(rwdir,'parent'))
666666
parent.git.submodule('add',self._small_repo_url(),'module')
667667
parent.index.commit("added submodule")
@@ -686,6 +686,37 @@ def test_git_submodules(self, rwdir):
686686
sm.move(sm.path+'_moved')
687687
sm2.move(sm2.path+'_moved')
688688

689+
parent.index.commit("moved submodules")
690+
691+
smm=sm.module()
692+
fp=os.path.join(smm.working_tree_dir,'empty-file')
693+
withopen(fp,'w'):
694+
pass
695+
smm.git.add(fp)
696+
smm.git.commit(m="new file added")
697+
698+
# submodules are retrieved from the current commit's tree, therefore we can't really get a new submodule
699+
# object pointing to the new submodule commit
700+
sm_too=parent.submodules[0]
701+
assertparent.head.commit.tree[sm.path].binsha==sm.binsha
702+
assertsm_too.binsha==sm.binsha,"cached submodule should point to the same commit as updated one"
703+
704+
added_bies=parent.index.add([sm])# addded base-index-entries
705+
assertlen(added_bies)==1
706+
parent.index.commit("add same submodule entry")
707+
commit_sm=parent.head.commit.tree[sm.path]
708+
assertcommit_sm.binsha==added_bies[0].binsha
709+
assertcommit_sm.binsha==sm.binsha
710+
711+
sm_too.binsha=sm_too.module().head.commit.binsha
712+
added_bies=parent.index.add([sm_too])
713+
assertlen(added_bies)==1
714+
parent.index.commit("add new submodule entry")
715+
commit_sm=parent.head.commit.tree[sm.path]
716+
assertcommit_sm.binsha==added_bies[0].binsha
717+
assertcommit_sm.binsha==sm_too.binsha
718+
assertsm_too.binsha!=sm.binsha
719+
689720
@with_rw_directory
690721
deftest_git_submodule_compatibility(self,rwdir):
691722
parent=git.Repo.init(os.path.join(rwdir,'parent'))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp