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.
pull/1205/head
Samuel Gaist 2022-10-26 17:19:12 +02:00
rodzic 6b8b2334e7
commit 3028d07182
1 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -627,8 +627,17 @@ class BuildPack:
if not exclude:
exclude = ["**/.git"]
for item in exclude_paths(".", exclude):
tar.add(item, f"src/{item}", filter=_filter_tar)
files_to_add = exclude_paths(".", exclude)
if files_to_add:
for item in files_to_add:
tar.add(item, f"src/{item}", filter=_filter_tar)
else:
# Either the source was empty or everything was filtered out.
# In any case, create an src dir so the build can proceed.
src = tarfile.TarInfo("src")
src.type = tarfile.DIRTYPE
tar.addfile(src)
tar.close()
tarf.seek(0)