Skip to content

Commit 6fd2ad2

Browse files
committed
fix: create src directory in any case
The original behavior was to create an src directory with the content of the repository. The creation would happen in any case (remote or local repository). With the filtering in place and the default to remove the .git folder, it breaks the build as the src folder can be missing. This patch ensures that the directory is present in the tar so the build can continue as it did until now.
1 parent d57886f commit 6fd2ad2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

repo2docker/buildpacks/base.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,17 @@ def _filter_tar(tarinfo):
627627
if not exclude:
628628
exclude = ["**/.git"]
629629

630-
for item in exclude_paths(".", exclude):
631-
tar.add(item, f"src/{item}", filter=_filter_tar)
630+
files_to_add = exclude_paths(".", exclude)
631+
632+
if files_to_add:
633+
for item in files_to_add:
634+
tar.add(item, f"src/{item}", filter=_filter_tar)
635+
else:
636+
# Either the source was empty or everything was filtered out.
637+
# In any case, create an src dir so the build can proceed.
638+
src = tarfile.TarInfo("src")
639+
src.type = tarfile.DIRTYPE
640+
tar.addfile(src)
632641

633642
tar.close()
634643
tarf.seek(0)

0 commit comments

Comments
 (0)