Skip to content

Commit

Permalink
Fix submodules are not walked through
Browse files Browse the repository at this point in the history
Instead of walking through submodules as repos,
they were included as directories.
Refs #37
  • Loading branch information
Kentzo committed Mar 2, 2017
1 parent 7ecea97 commit 502ea53
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions git_archive_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ def walk_git_files(self, repo_path=''):
for repo_file_path in repo_file_paths:
# Git puts path in quotes if file path has unicode characters.
repo_file_path = repo_file_path.strip('"') # file path relative to current repo
file_name = path.basename(repo_file_path)
repo_file_abspath = path.join(repo_abspath, repo_file_path) # absolute file path
main_repo_file_path = path.join(repo_path, repo_file_path) # file path relative to the main repo

# Only list symlinks and files.
if not path.islink(main_repo_file_path) and path.isdir(main_repo_file_path):
if not path.islink(repo_file_abspath) and path.isdir(repo_file_abspath):
continue

if self.is_file_excluded(repo_abspath, repo_file_path, exclude_patterns):
Expand All @@ -315,18 +315,23 @@ def walk_git_files(self, repo_path=''):
self.run_shell("git submodule init", repo_abspath)
self.run_shell("git submodule update", repo_abspath)

gitmodulesfile = path.join(repo_path, ".gitmodules")
if path.isfile(gitmodulesfile):
with open(gitmodulesfile) as f:
try:
repo_gitmodules_path = path.join(repo_abspath, ".gitmodules")

with open(repo_gitmodules_path) as f:
lines = f.readlines()

for l in lines:
m = re.match("^\s*path\s*=\s*(.*)\s*$", l)

if m:
submodule_path = m.group(1)
submodule_path = path.join(repo_path, submodule_path)
for file_path in self.walk_git_files(submodule_path):
yield file_path

for submodule_file_path in self.walk_git_files(submodule_path):
yield submodule_file_path
except FileNotFoundError:
pass

@staticmethod
def get_path_components(repo_abspath, abspath):
Expand Down

0 comments on commit 502ea53

Please sign in to comment.