Skip to content

Commit bbe9f65

Browse files
Merge pull request #81654 from nate-chandler/update-checkout/20250520/1
[update-checkout] Gracefully degrade timestamp matching.
2 parents 689491c + 77376b6 commit bbe9f65

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

utils/update_checkout/update_checkout/update_checkout.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,15 @@ def confirm_tag_in_repo(tag, repo_name) -> Optional[str]:
100100

101101

102102
def find_rev_by_timestamp(timestamp, repo_name, refspec):
103+
refspec_exists = True
104+
try:
105+
shell.run(["git", "rev-parse", "--verify", refspec])
106+
except Exception:
107+
refspec_exists = False
103108
args = ["git", "log", "-1", "--format=%H", "--first-parent",
104-
'--before=' + timestamp, refspec]
109+
'--before=' + timestamp]
110+
if refspec_exists:
111+
args.append(refspec)
105112
rev = shell.capture(args).strip()
106113
if rev:
107114
return rev

0 commit comments

Comments
 (0)