Include hidden files by default in a package

This commit is contained in:
Ivan Kravets
2020-01-05 18:29:19 +02:00
parent 5ab34436ec
commit 60139035d8
2 changed files with 13 additions and 3 deletions

View File

@@ -26,7 +26,14 @@ from platformio.unpacker import FileUnpacker
class PackagePacker(object):
EXCLUDE_DEFAULT = ["._*", ".DS_Store", ".git", ".hg", ".svn", ".pio"]
EXCLUDE_DEFAULT = [
"._*",
".DS_Store",
".git",
".hg",
".svn",
".pio",
]
INCLUDE_DEFAULT = ManifestFileType.items().values()
def __init__(self, package, manifest_uri=None):
@@ -116,7 +123,7 @@ class PackagePacker(object):
return dst
def compute_src_filters(self, include, exclude):
result = ["+<%s>" % p for p in include or ["*"]]
result = ["+<%s>" % p for p in include or ["*", ".*"]]
result += ["-<%s>" % p for p in exclude or []]
result += ["-<%s>" % p for p in self.EXCLUDE_DEFAULT]
# automatically include manifests

View File

@@ -26,6 +26,9 @@ from platformio.package.pack import PackagePacker
def test_base(tmpdir_factory):
pkg_dir = tmpdir_factory.mktemp("package")
pkg_dir.join(".git").mkdir().join("file").write("")
pkg_dir.join(".gitignore").write("tests")
pkg_dir.join("._ignored").write("")
pkg_dir.join("main.cpp").write("#include <stdio.h>")
p = PackagePacker(str(pkg_dir))
# test missed manifest
@@ -38,7 +41,7 @@ def test_base(tmpdir_factory):
p.pack()
with tarfile.open(os.path.join(str(pkg_dir), "foo-1.0.0.tar.gz"), "r:gz") as tar:
assert set(tar.getnames()) == set(
["include/main.h", "library.json", "main.cpp"]
[".gitignore", "include/main.h", "library.json", "main.cpp"]
)