Check if the diff is only in code examples of the doc in a filename. Args: repo (`git.Repo`): A git repository (for instance the Transformers repo). branching_point (`str`): The commit reference of where to compare for the diff. filename (`str`): The filename where
(repo: Repo, branching_point: str, filename: str)
| 207 | |
| 208 | |
| 209 | def diff_contains_doc_examples(repo: Repo, branching_point: str, filename: str) -> bool: |
| 210 | """ |
| 211 | Check if the diff is only in code examples of the doc in a filename. |
| 212 | |
| 213 | Args: |
| 214 | repo (`git.Repo`): A git repository (for instance the Transformers repo). |
| 215 | branching_point (`str`): The commit reference of where to compare for the diff. |
| 216 | filename (`str`): The filename where we want to know if the diff is only in codes examples. |
| 217 | |
| 218 | Returns: |
| 219 | `bool`: Whether the diff is only in code examples of the doc or not. |
| 220 | """ |
| 221 | folder = Path(repo.working_dir) |
| 222 | with checkout_commit(repo, branching_point): |
| 223 | with open(folder / filename, "r", encoding="utf-8") as f: |
| 224 | old_content = f.read() |
| 225 | |
| 226 | with open(folder / filename, "r", encoding="utf-8") as f: |
| 227 | new_content = f.read() |
| 228 | |
| 229 | old_content_clean = keep_doc_examples_only(old_content) |
| 230 | new_content_clean = keep_doc_examples_only(new_content) |
| 231 | |
| 232 | return old_content_clean != new_content_clean |
| 233 | |
| 234 | |
| 235 | def get_diff(repo: Repo, base_commit: str, commits: List[str]) -> List[str]: |
no test coverage detected
searching dependent graphs…