MCPcopy Create free account
hub / github.com/apache/tvm / get_git_files

Function get_git_files

tests/lint/check_asf_header.py:220–248  ·  view source on GitHub ↗

Get list of files tracked by git (excluding files staged for deletion).

()

Source from the content-addressed store, hash-verified

218
219
220def get_git_files() -> list[str] | None:
221 """Get list of files tracked by git (excluding files staged for deletion)."""
222 try:
223 result = subprocess.run(
224 ["git", "ls-files"], check=False, capture_output=True, text=True, cwd=Path.cwd()
225 )
226 if result.returncode != 0:
227 print("Error: Could not get git files. Make sure you're in a git repository.")
228 print("Git command failed:", result.stderr.strip())
229 return None
230 all_files = {line.strip() for line in result.stdout.split("\n") if line.strip()}
231 # Exclude files staged for deletion so the header check does not
232 # report errors for files that are intentionally being removed.
233 deleted_result = subprocess.run(
234 ["git", "ls-files", "--deleted"],
235 check=False,
236 capture_output=True,
237 text=True,
238 cwd=Path.cwd(),
239 )
240 if deleted_result.returncode == 0:
241 deleted = {line.strip() for line in deleted_result.stdout.split("\n") if line.strip()}
242 all_files -= deleted
243 elif deleted_result.stderr:
244 print(f"Warning: 'git ls-files --deleted' failed: {deleted_result.stderr.strip()}")
245 return sorted(all_files)
246 except FileNotFoundError:
247 print("Error: Git not found. This tool requires git to be installed.")
248 return None
249
250
251def copyright_line(line: str) -> bool:

Callers 1

collect_filesFunction · 0.85

Calls 3

printFunction · 0.85
runMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…