mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Bugfix: Correctly detect test changes in PRs (#101304)
Fixes a bug where the logic for deciding what tests have been edited by a PR would include all files that had been edited since the merge base, including files that were in main! Now it will only consider the files that are part of the PR itself Pull Request resolved: https://github.com/pytorch/pytorch/pull/101304 Approved by: https://github.com/seemethere, https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
d75f93603a
commit
ceecccc09e
@ -116,8 +116,14 @@ def calculate_shards(
|
||||
|
||||
def _query_changed_test_files() -> List[str]:
|
||||
default_branch = f"origin/{os.environ.get('GIT_DEFAULT_BRANCH', 'main')}"
|
||||
cmd = ["git", "diff", "--name-only", default_branch, "HEAD"]
|
||||
proc = subprocess.run(cmd, capture_output=True)
|
||||
merge_base = (
|
||||
subprocess.check_output(["git", "merge-base", default_branch, "HEAD"])
|
||||
.decode()
|
||||
.strip()
|
||||
)
|
||||
proc = subprocess.run(
|
||||
["git", "diff", "--name-only", merge_base, "HEAD"], capture_output=True
|
||||
)
|
||||
|
||||
if proc.returncode != 0:
|
||||
raise RuntimeError("Unable to get changed files")
|
||||
|
Reference in New Issue
Block a user