MCPcopy Create free account
hub / github.com/pytorch/executorch / is_doc_only_commit

Function is_doc_only_commit

scripts/pick_doc_commits.py:113–140  ·  view source on GitHub ↗

Returns True if the commit only touched "documentation files".

(commit: Commit)

Source from the content-addressed store, hash-verified

111
112
113def is_doc_only_commit(commit: Commit) -> bool:
114 """Returns True if the commit only touched "documentation files"."""
115
116 def is_doc_file(path: str) -> bool:
117 """Returns true if the path is considered to be a "documentation file"."""
118 return (
119 # Everything under docs, regardless of the file type.
120 path.startswith("docs/")
121 # Any markdown or RST file in the repo.
122 or path.endswith(".md")
123 or path.endswith(".rst")
124 )
125
126 # The first line is the full hash, and the rest are the files modified by
127 # the commit, relative to the root of the repo.
128 lines = run_git(["diff-tree", "--name-only", "-r", commit.hash])
129 all_files = frozenset(lines[1:])
130 doc_files = frozenset(filter(is_doc_file, all_files))
131 non_doc_files = all_files - doc_files
132 is_doc_only = (all_files == doc_files) and len(all_files) > 0
133
134 if verbosity > 0 and not is_doc_only:
135 debug_log(
136 f"{repr(commit)} touches {len(non_doc_files)} non-doc files, "
137 + f"like '{sorted(non_doc_files)[0]}'."
138 )
139
140 return is_doc_only
141
142
143def print_wrapped(text: str, width: int = 80) -> None:

Callers 1

mainFunction · 0.85

Calls 2

run_gitFunction · 0.85
debug_logFunction · 0.85

Tested by

no test coverage detected