|
2 | 2 | # This module is part of GitPython and is released under
|
3 | 3 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php
|
4 | 4 | import os
|
| 5 | +import shutil |
5 | 6 | import sys
|
6 | 7 | from unittest import skipIf
|
7 | 8 |
|
@@ -660,6 +661,24 @@ def test_add_empty_repo(self, rwdir):
|
660 | 661 | url=empty_repo_dir, no_checkout=checkout_mode and True or False)
|
661 | 662 | # end for each checkout mode
|
662 | 663 |
|
| 664 | + @with_rw_directory |
| 665 | + def test_list_only_valid_submodules(self, rwdir): |
| 666 | + repo_path = osp.join(rwdir, 'parent') |
| 667 | + repo = git.Repo.init(repo_path) |
| 668 | + repo.git.submodule('add', self._small_repo_url(), 'module') |
| 669 | + repo.index.commit("add submodule") |
| 670 | + |
| 671 | + assert len(repo.submodules) == 1 |
| 672 | + |
| 673 | + # Delete the directory from submodule |
| 674 | + submodule_path = osp.join(repo_path, 'module') |
| 675 | + shutil.rmtree(submodule_path) |
| 676 | + repo.git.add([submodule_path]) |
| 677 | + repo.index.commit("remove submodule") |
| 678 | + |
| 679 | + repo = git.Repo(repo_path) |
| 680 | + assert len(repo.submodules) == 0 |
| 681 | + |
663 | 682 | @skipIf(HIDE_WINDOWS_KNOWN_ERRORS,
|
664 | 683 | """FIXME on cygwin: File "C:\\projects\\gitpython\\git\\cmd.py", line 671, in execute
|
665 | 684 | raise GitCommandError(command, status, stderr_value, stdout_value)
|
|
0 commit comments