mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
[ez] Add try catch for deleting old branches (#119696)
I think some chars in branch names affect the api calls, so just assume they're protected Pull Request resolved: https://github.com/pytorch/pytorch/pull/119696 Approved by: https://github.com/huydhn
This commit is contained in:
parent
7eecbf8a30
commit
ad217d4266
1 changed files with 9 additions and 5 deletions
14
.github/scripts/delete_old_branches.py
vendored
14
.github/scripts/delete_old_branches.py
vendored
|
|
@ -95,11 +95,15 @@ query ($owner: String!, $repo: String!, $cursor: String) {
|
|||
|
||||
|
||||
def is_protected(branch: str) -> bool:
|
||||
ESTIMATED_TOKENS[0] += 1
|
||||
res = gh_fetch_json_dict(
|
||||
f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/branches/{branch}"
|
||||
)
|
||||
return bool(res["protected"])
|
||||
try:
|
||||
ESTIMATED_TOKENS[0] += 1
|
||||
res = gh_fetch_json_dict(
|
||||
f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/branches/{branch}"
|
||||
)
|
||||
return bool(res["protected"])
|
||||
except Exception as e:
|
||||
print(f"[{branch}] Failed to fetch branch protections: {e}")
|
||||
return True
|
||||
|
||||
|
||||
def convert_gh_timestamp(date: str) -> float:
|
||||
|
|
|
|||
Loading…
Reference in a new issue