Return a list of python files that have been modified between: - the current head and the main branch if `diff_with_last_commit=False` (default) - the current head and its parent commit otherwise. Returns: `List[str]`: The list of Python files with a diff (files added, ren
(diff_with_last_commit: bool = False)
| 275 | |
| 276 | |
| 277 | def get_modified_python_files(diff_with_last_commit: bool = False) -> List[str]: |
| 278 | """ |
| 279 | Return a list of python files that have been modified between: |
| 280 | |
| 281 | - the current head and the main branch if `diff_with_last_commit=False` (default) |
| 282 | - the current head and its parent commit otherwise. |
| 283 | |
| 284 | Returns: |
| 285 | `List[str]`: The list of Python files with a diff (files added, renamed or deleted are always returned, files |
| 286 | modified are returned if the diff in the file is not only in docstrings or comments, see |
| 287 | `diff_is_docstring_only`). |
| 288 | """ |
| 289 | repo = Repo(PATH_TO_REPO) |
| 290 | |
| 291 | if not diff_with_last_commit: |
| 292 | # Need to fetch refs for main using remotes when running with github actions. |
| 293 | upstream_main = repo.remotes.origin.refs.main |
| 294 | |
| 295 | print(f"main is at {upstream_main.commit}") |
| 296 | print(f"Current head is at {repo.head.commit}") |
| 297 | |
| 298 | branching_commits = repo.merge_base(upstream_main, repo.head) |
| 299 | for commit in branching_commits: |
| 300 | print(f"Branching commit: {commit}") |
| 301 | return get_diff(repo, repo.head.commit, branching_commits) |
| 302 | else: |
| 303 | print(f"main is at {repo.head.commit}") |
| 304 | parent_commits = repo.head.commit.parents |
| 305 | for commit in parent_commits: |
| 306 | print(f"Parent commit: {commit}") |
| 307 | return get_diff(repo, repo.head.commit, parent_commits) |
| 308 | |
| 309 | |
| 310 | def get_diff_for_doctesting(repo: Repo, base_commit: str, commits: List[str]) -> List[str]: |
no test coverage detected
searching dependent graphs…