Skip to content

Commit e15dc09

Browse files
authored
Merge pull request #382 from bgilbert/export
Filter additional files from sdist and GitHub source archive
2 parents 22dcac2 + 6372e5a commit e15dc09

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
.gitattributes export-ignore
66
.gitignore export-ignore
77
/.github/ISSUE_TEMPLATE export-ignore
8+
/.github/maintainer export-ignore
89
/.github/workflows export-ignore
910
/.pre-commit-config.yaml export-ignore
11+
/meson.format export-ignore
1012
/pyproject.toml export-ignore

common/software.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,33 @@ class Project(Software):
115115
anitya_id: int | None = None
116116
primary: bool = False
117117
remove_dirs: Iterable[str] = ()
118-
# overrides for default file removals
118+
# overrides for default dir/file removals
119+
keep_dirs: Iterable[str] = ()
119120
keep_files: Iterable[str] = ()
120121

122+
DIST_REMOVE_DIRNAMES = {
123+
'.github',
124+
'.gitlab',
125+
'.gitlab-ci',
126+
'.gitlab-ci.d',
127+
}
121128
DIST_REMOVE_FILENAMES = {
129+
'.appveyor.yml',
130+
'.cirrus.yml',
131+
'.clang-format',
132+
'.cmake-format.yaml',
133+
'.codecov.yaml',
134+
'.codespellrc',
135+
'.editorconfig',
136+
'.flake8',
137+
'.gitattributes',
138+
'.gitignore',
139+
'.gitlab-ci.yml',
140+
'.gitmodules',
141+
'.lcovrc',
142+
'.readthedocs.yaml',
143+
'.shellcheckrc',
144+
'.travis.yml',
122145
'CMakeLists.txt',
123146
'configure',
124147
'configure.ac',
@@ -227,7 +250,14 @@ def walkerr(e: OSError) -> None:
227250
return
228251
for subdir in self.remove_dirs:
229252
shutil.rmtree(projdir / subdir)
230-
for dirpath, _, filenames in projdir.walk(on_error=walkerr):
253+
for dirpath, dirnames, filenames in projdir.walk(on_error=walkerr):
254+
for dirname in dirnames:
255+
path = dirpath / dirname
256+
if path.relative_to(projdir).as_posix() in self.keep_dirs:
257+
continue
258+
if path.name in self.DIST_REMOVE_DIRNAMES:
259+
dirnames.remove(path.name)
260+
shutil.rmtree(path)
231261
for filename in filenames:
232262
path = dirpath / filename
233263
if path.relative_to(projdir).as_posix() in self.keep_files:
@@ -323,6 +353,7 @@ def _sqlite3_license(proj: Project) -> tuple[str, str]:
323353
display='glib',
324354
licenses=['COPYING'],
325355
remove_dirs=['gio/tests', 'glib/tests', 'gobject/tests', 'po'],
356+
keep_dirs=['.gitlab-ci'],
326357
keep_files=[
327358
'm4macros/glib-2.0.m4',
328359
'm4macros/glib-gettext.m4',

0 commit comments

Comments
 (0)