8000 Reference the commit explicitly (#148026) · pytorch/pytorch@10ffd94 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10ffd94

Browse files
ZainRizvipytorchmergebot
authored andcommitted
Reference the commit explicitly (#148026)
Reference the commit tested by CI explicitly, and fail the merge if the PR was updated. Tested locally Pull Request resolved: #148026 Approved by: https://github.com/seemethere, https://github.com/malfet, https://github.com/atalman
1 parent 783d83c commit 10ffd94

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

.github/scripts/trymerge.py

Lines changed: 9 additions & 1 deletion
< 8000 /div>
Original file line numberDiff line numberDiff line change
@@ -1224,9 +1224,17 @@ def merge_changes(
12241224
if not self.is_ghstack_pr():
12251225
msg = self.gen_commit_message()
12261226
pr_branch_name = f"__pull-request-{self.pr_num}__init__"
1227-
repo.fetch(f"pull/{self.pr_num}/head", pr_branch_name)
1227+
repo.fetch(self.last_commit()["oid"], pr_branch_name)
12281228
repo._run_git("merge", "--squash", pr_branch_name)
12291229
repo._run_git("commit", f'--author="{self.get_author()}"', "-m", msg)
1230+
1231+
# Did the PR change since we started the merge?
1232+
pulled_sha = repo.show_ref(pr_branch_name)
1233+
latest_pr_status = GitHubPR(self.org, self.project, self.pr_num)
1234+
if pulled_sha != latest_pr_status.last_commit()["oid"]:
1235+
raise RuntimeError(
1236+
"PR has been updated since CI checks last passed. Please rerun the merge command."
1237+
)
12301238
return []
12311239
else:
12321240
return self.merge_ghstack_into(

0 commit comments

Comments
 (0)
0