Skip to content

Commit b904481

Browse files
committed
Fix precommit hook to extract commit hash from nightly commit title instead of using the nightly commit hash
As titled.
1 parent a12219d commit b904481

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

.github/scripts/update_pytorch_pin.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import re
55
import sys
66
import urllib.request
7-
from datetime import datetime
87

98

109
def parse_nightly_version(nightly_version):
@@ -75,13 +74,20 @@ def get_commit_hash_for_nightly(date_str):
7574
# Check if the first line of commit message matches
7675
first_line = commit_msg.split("\n")[0].strip()
7776
if first_line == target_title or first_line.startswith(f"{date_str} nightly"):
78-
return commit["sha"]
77+
return extract_hash_from_title(first_line)
7978

8079
raise ValueError(
8180
f"Could not find commit with title matching '{target_title}' in nightly branch"
8281
)
8382

8483

84+
def extract_hash_from_title(title):
85+
match = re.search(r"\(([0-9a-fA-F]{7,40})\)", title)
86+
if not match:
87+
raise ValueError(f"Could not extract commit hash from title '{title}'")
88+
return match.group(1)
89+
90+
8591
def update_pytorch_pin(commit_hash):
8692
"""
8793
Update .ci/docker/ci_commit_pins/pytorch.txt with the new commit hash.

0 commit comments

Comments
 (0)