From 9112fd451e4c0e557d8ab3c05ea3097136f9c78c Mon Sep 17 00:00:00 2001 From: Antoine Lambert <anlambert@softwareheritage.org> Date: Tue, 16 Jan 2024 14:07:14 +0100 Subject: [PATCH] directory: Ensure to yield repo path when no .gitmodules file is found If the submodules parameter of the loader is True but no .gitmodules file is found in root directory of the repository, the repository path is not yielded and thus its loading discarded. --- swh/loader/git/directory.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/swh/loader/git/directory.py b/swh/loader/git/directory.py index 24a27d20..dc07a637 100644 --- a/swh/loader/git/directory.py +++ b/swh/loader/git/directory.py @@ -115,9 +115,7 @@ class GitCheckoutLoader(BaseDirectoryLoader): repo_path = checkout_repository_ref( self.origin.url, self.git_ref, target=Path(tmpdir) ) - if not self.submodules: - yield repo_path - else: + if self.submodules: local_clone = str(repo_path) gitmodules_path = join(local_clone, ".gitmodules") if exists(gitmodules_path): @@ -136,8 +134,7 @@ class GitCheckoutLoader(BaseDirectoryLoader): ) # restore original .gitmodules file in case it was modified above check_output([git(), "checkout", "."], cwd=local_clone) - - yield repo_path + yield repo_path def build_snapshot(self) -> Snapshot: """Build snapshot without losing the git reference context.""" -- GitLab