treex-cli 0.1.10__tar.gz → 0.1.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {treex_cli-0.1.10/treex_cli.egg-info → treex_cli-0.1.11}/PKG-INFO +1 -1
- {treex_cli-0.1.10 → treex_cli-0.1.11}/pyproject.toml +1 -1
- {treex_cli-0.1.10 → treex_cli-0.1.11}/treex.py +43 -18
- {treex_cli-0.1.10 → treex_cli-0.1.11/treex_cli.egg-info}/PKG-INFO +1 -1
- {treex_cli-0.1.10 → treex_cli-0.1.11}/LICENSE +0 -0
- {treex_cli-0.1.10 → treex_cli-0.1.11}/README.md +0 -0
- {treex_cli-0.1.10 → treex_cli-0.1.11}/setup.cfg +0 -0
- {treex_cli-0.1.10 → treex_cli-0.1.11}/treex_cli.egg-info/SOURCES.txt +0 -0
- {treex_cli-0.1.10 → treex_cli-0.1.11}/treex_cli.egg-info/dependency_links.txt +0 -0
- {treex_cli-0.1.10 → treex_cli-0.1.11}/treex_cli.egg-info/entry_points.txt +0 -0
- {treex_cli-0.1.10 → treex_cli-0.1.11}/treex_cli.egg-info/top_level.txt +0 -0
|
@@ -43,22 +43,40 @@ class GitIgnore:
|
|
|
43
43
|
self.enabled = True
|
|
44
44
|
|
|
45
45
|
def ignored(self, path):
|
|
46
|
-
"""Check if Git considers
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
"""Check if Git considers a path ignored."""
|
|
47
|
+
return bool(self.ignored_many([path]))
|
|
48
|
+
|
|
49
|
+
def ignored_many(self, paths):
|
|
50
|
+
"""Check which paths Git considers ignored."""
|
|
51
|
+
if not self.enabled or self.repo_root is None:
|
|
52
|
+
return set()
|
|
53
|
+
relative_paths = []
|
|
54
|
+
for path in paths:
|
|
55
|
+
try:
|
|
56
|
+
relative = path.resolve().relative_to(self.repo_root)
|
|
57
|
+
except (ValueError, OSError):
|
|
58
|
+
continue
|
|
59
|
+
relative_paths.append(relative.as_posix())
|
|
60
|
+
if not relative_paths:
|
|
61
|
+
return set()
|
|
49
62
|
try:
|
|
50
|
-
|
|
63
|
+
# Check all paths in one Git call.
|
|
64
|
+
# -z uses NUL delimiters to safely handle filenames
|
|
65
|
+
# containing special characters.
|
|
51
66
|
result = subprocess.run(
|
|
52
|
-
["git", "check-ignore", "--
|
|
67
|
+
["git", "check-ignore", "--stdin", "-z"],
|
|
53
68
|
cwd=self.repo_root,
|
|
54
|
-
|
|
69
|
+
input="\0".join(relative_paths) + "\0",
|
|
70
|
+
stdout=subprocess.PIPE,
|
|
55
71
|
stderr=subprocess.DEVNULL,
|
|
72
|
+
text=True,
|
|
56
73
|
check=False,
|
|
57
74
|
)
|
|
58
|
-
except
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
return
|
|
75
|
+
except OSError:
|
|
76
|
+
return set()
|
|
77
|
+
if result.returncode not in (0, 1):
|
|
78
|
+
return set()
|
|
79
|
+
return set(result.stdout.split("\0")) - {""}
|
|
62
80
|
|
|
63
81
|
|
|
64
82
|
def _format_size(size):
|
|
@@ -132,14 +150,21 @@ def _get_tree_entries(path, gitignore):
|
|
|
132
150
|
entries = list(path.iterdir())
|
|
133
151
|
except PermissionError:
|
|
134
152
|
return None
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
entry
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
entries = [entry for entry in entries if not entry.is_symlink()]
|
|
154
|
+
if gitignore is not None:
|
|
155
|
+
entries = [entry for entry in entries if entry.name != ".git"]
|
|
156
|
+
if gitignore.enabled and gitignore.repo_root is not None:
|
|
157
|
+
ignored = gitignore.ignored_many(entries)
|
|
158
|
+
filtered_entries = []
|
|
159
|
+
for entry in entries:
|
|
160
|
+
try:
|
|
161
|
+
relative = entry.resolve().relative_to(gitignore.repo_root)
|
|
162
|
+
except (ValueError, OSError):
|
|
163
|
+
filtered_entries.append(entry)
|
|
164
|
+
continue
|
|
165
|
+
if relative.as_posix() not in ignored:
|
|
166
|
+
filtered_entries.append(entry)
|
|
167
|
+
entries = filtered_entries
|
|
143
168
|
entries.sort(key=lambda p: (p.is_file(), p.name.casefold()))
|
|
144
169
|
return entries
|
|
145
170
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|