Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion vcs2l/clients/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def get_git_version(cls):

@staticmethod
def is_repository(path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should conform to recognizing submodules as how they are defined in the parent repository. On git this is by using the .gitmodules file in the parent repository. See https://git-scm.com/docs/gitmodules.

If you check the contents of the .git file that you are recognizing it is a link to the git dir on ../../.git/modules.

With the example from the test of this PR:


cat .git
gitdir: ../../.git/modules/temp/vcstool

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the --nested flag for vcs export, recursively searches all the subdirectories of the parent directory and determines if the directory is a repository by using the is_repository function.

I guess when the --nested flag is active, instead of using recursion, this would be cleaner to determine all the submodules from the .gitmodules file.

return os.path.isdir(os.path.join(path, '.git'))
"""Check if the given path is a git repository or a submodule."""
return os.path.isdir(os.path.join(path, '.git')) or os.path.isfile(
os.path.join(path, '.git')
)

def __init__(self, path):
super(GitClient, self).__init__(path)
Expand Down
Loading