From 0e577f5066deafe024d109904d34956566d49f89 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Sun, 23 Dec 2018 21:25:05 -0500 Subject: [PATCH 1/3] Add test --- git/test/test_submodule.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py index 0bf763801..2703ad6fe 100644 --- a/git/test/test_submodule.py +++ b/git/test/test_submodule.py @@ -2,6 +2,7 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php import os +import shutil import sys from unittest import skipIf @@ -660,6 +661,24 @@ def test_add_empty_repo(self, rwdir): url=empty_repo_dir, no_checkout=checkout_mode and True or False) # end for each checkout mode + @with_rw_directory + def test_list_only_valid_submodules(self, rwdir): + repo_path = osp.join(rwdir, 'parent') + repo = git.Repo.init(repo_path) + repo.git.submodule('add', self._small_repo_url(), 'module') + repo.index.commit("add submodule") + + assert len(repo.submodules) == 1 + + # Delete the directory from submodule + submodule_path = osp.join(repo_path, 'module') + shutil.rmtree(submodule_path) + repo.git.add([submodule_path]) + repo.index.commit("remove submodule") + + repo = git.Repo(repo_path) + assert len(repo.submodules) == 0 + @skipIf(HIDE_WINDOWS_KNOWN_ERRORS, """FIXME on cygwin: File "C:\\projects\\gitpython\\git\\cmd.py", line 671, in execute raise GitCommandError(command, status, stderr_value, stdout_value) From 4bed109353250673ca6bdaee44c2cfb8dd5845d7 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Sun, 23 Dec 2018 21:28:17 -0500 Subject: [PATCH 2/3] Skip on keyerror --- git/objects/submodule/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 446c88fcd..a75826eb3 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -1184,8 +1184,9 @@ def iter_items(cls, repo, parent_commit='HEAD'): entry = index.entries[index.entry_key(p, 0)] sm = Submodule(repo, entry.binsha, entry.mode, entry.path) except KeyError: - raise InvalidGitRepositoryError( - "Gitmodule path %r did not exist in revision of parent commit %s" % (p, parent_commit)) + # The submodule doesn't exist, probably it wasn't + # removed from the .gitmodules file. + continue # END handle keyerror # END handle critical error From 6a235bc655951585a66c0c59ed0a527c231284c6 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Sat, 2 Feb 2019 00:30:07 -0500 Subject: [PATCH 3/3] Fix test --- git/test/test_submodule.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py index 2703ad6fe..94028d834 100644 --- a/git/test/test_submodule.py +++ b/git/test/test_submodule.py @@ -480,9 +480,8 @@ def test_root_module(self, rwrepo): with sm.config_writer() as writer: writer.set_value('path', fp) # change path to something with prefix AFTER url change - # update fails as list_items in such a situations cannot work, as it cannot - # find the entry at the changed path - self.failUnlessRaises(InvalidGitRepositoryError, rm.update, recursive=False) + # update doesn't fail, because list_items ignores the wrong path in such situations. + rm.update(recursive=False) # move it properly - doesn't work as it its path currently points to an indexentry # which doesn't exist ( move it to some path, it doesn't matter here ) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy