Skip to content

Commit 8017421

Browse files
authored
Merge pull request #1647 from CosmosAtlas/master
Added test for PR #1645 submodule path
2 parents 11839ab + fafb4f6 commit 8017421

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ Contributors are:
5151
-Luke Twist <itsluketwist@gmail.com>
5252
-Joseph Hale <me _at_ jhale.dev>
5353
-Santos Gallegos <stsewd _at_ proton.me>
54+
-Wenhan Zhu <wzhu.cosmos _at_ gmail.com>
5455
Portions derived from other open source works and are clearly marked.

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ See [Issue #525](https://github.com/gitpython-developers/GitPython/issues/525).
9393

9494
### RUNNING TESTS
9595

96-
_Important_: Right after cloning this repository, please be sure to have executed
97-
the `./init-tests-after-clone.sh` script in the repository root. Otherwise
98-
you will encounter test failures.
96+
_Important_: Right after cloning this repository, please be sure to have
97+
executed `git fetch --tags` followed by the `./init-tests-after-clone.sh`
98+
script in the repository root. Otherwise you will encounter test failures.
9999

100100
On _Windows_, make sure you have `git-daemon` in your PATH. For MINGW-git, the `git-daemon.exe`
101101
exists in `Git\mingw64\libexec\git-core\`; CYGWIN has no daemon, but should get along fine

test/test_submodule.py

+22
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,28 @@ def assert_exists(sm, value=True):
906906
assert osp.isdir(sm_module_path) == dry_run
907907
# end for each dry-run mode
908908

909+
@with_rw_directory
910+
def test_ignore_non_submodule_file(self, rwdir):
911+
parent = git.Repo.init(rwdir)
912+
913+
smp = osp.join(rwdir, "module")
914+
os.mkdir(smp)
915+
916+
with open(osp.join(smp, "a"), "w", encoding="utf-8") as f:
917+
f.write('test\n')
918+
919+
with open(osp.join(rwdir, ".gitmodules"), "w", encoding="utf-8") as f:
920+
f.write("[submodule \"a\"]\n")
921+
f.write(" path = module\n")
922+
f.write(" url = https://github.com/chaconinc/DbConnector\n")
923+
924+
parent.git.add(Git.polish_url(osp.join(smp, "a")))
925+
parent.git.add(Git.polish_url(osp.join(rwdir, ".gitmodules")))
926+
927+
parent.git.commit(message='test')
928+
929+
assert len(parent.submodules) == 0
930+
909931
@with_rw_directory
910932
def test_remove_norefs(self, rwdir):
911933
parent = git.Repo.init(osp.join(rwdir, "parent"))

0 commit comments

Comments
 (0)