Skip to content

Commit cee6455

Browse files
committed
feat: add mode
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 6819405 commit cee6455

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ sdist-only = []
8383
git-only = []
8484
default-ignore = true
8585
recurse-submodules = true
86+
mode = "git"
8687
```
8788

8889
You can add `.gitignore` style lines here, and you can turn off the default
@@ -92,6 +93,10 @@ By default, check-sdist recursively scans the contents of Git submodules, but
9293
you can disable this behavior (e.g. to support older Git versions that don't
9394
have this capability).
9495

96+
You can also select `mode = "all"`, which will instead check every file on your
97+
system. Be prepared to ignore lots of things manually, like `*.pyc` files, if
98+
you use this.
99+
95100
### See also
96101

97102
- [check-manifest](https://github.com/mgedmin/check-manifest): A (currently)

scripts/generate_schema.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
items:
2323
type: string
2424
git-only:
25-
description: Files that are only in Git. Gitignore style lines.
25+
description: Files that are only in Git (or whatever mode you use). Gitignore style lines.
2626
type: array
2727
items:
2828
type: string
@@ -34,6 +34,12 @@
3434
description: Look in all submodules too.
3535
default: true
3636
type: boolean
37+
mode:
38+
description: What to use as baseline
39+
default: git
40+
enum:
41+
- git
42+
- all
3743
"""
3844

3945
schema = yaml.safe_load(starter)

src/check_sdist/__main__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,20 @@ def compare(
6969
git_only_patterns = config.get("git-only", [])
7070
default_ignore = config.get("default-ignore", True)
7171
recurse_submodules = config.get("recurse-submodules", True)
72+
mode = config.get("mode", "git")
7273

7374
sdist = sdist_files(source_dir, isolated=isolated, installer=installer) - {
7475
"PKG-INFO"
7576
}
76-
git = git_files(source_dir, recurse_submodules=recurse_submodules)
77+
if mode == "git":
78+
git = git_files(source_dir, recurse_submodules=recurse_submodules)
79+
elif mode == "all":
80+
git = frozenset(
81+
str(p.relative_to(source_dir)) for p in source_dir.rglob("*") if p.is_file()
82+
)
83+
else:
84+
msg = "Only 'all' and 'git' supported for 'mode'"
85+
raise ValueError(msg)
7786

7887
if default_ignore:
7988
with resources.joinpath("default-ignore.txt").open("r", encoding="utf-8") as f:

src/check_sdist/resources/check-sdist.schema.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414
},
1515
"git-only": {
16-
"description": "Files that are only in Git. Gitignore style lines.",
16+
"description": "Files that are only in Git (or whatever mode you use). Gitignore style lines.",
1717
"type": "array",
1818
"items": {
1919
"type": "string"
@@ -28,6 +28,11 @@
2828
"description": "Look in all submodules too.",
2929
"default": true,
3030
"type": "boolean"
31+
},
32+
"mode": {
33+
"description": "What to use as baseline",
34+
"default": "git",
35+
"enum": ["git", "all"]
3136
}
3237
}
3338
}

src/check_sdist/resources/default-ignore.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ noxfile.py
55
.coverage
66
codecov.yml
77
*.dist-info
8+
*.pyc

0 commit comments

Comments
 (0)