Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit340c412

Browse files
zengk95pytorchmergebot
authored andcommitted
[mergebot] Add all-green option (#77660)
Since we released on-green, some people have requested an all green option to include everything.I was thinking of how to best add this into find_matching_merge_rule but I couldn't think of a good a great way since the option isn't really a merge_rule, rather overriding it so I just put it outside the method.Pull Requestresolved:#77660Approved by:https://github.com/janeyx99
1 parent1b878b4 commit340c412

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

‎.github/scripts/trymerge.py‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ def parse_args() -> Any:
384384
parser=ArgumentParser("Merge PR into default branch")
385385
parser.add_argument("--dry-run",action="store_true")
386386
parser.add_argument("--on-green",action="store_true")
387+
parser.add_argument("--all-green",action="store_true")
387388
parser.add_argument("--revert",action="store_true")
388389
parser.add_argument("--force",action="store_true")
389390
parser.add_argument("--comment-id",type=int)
@@ -887,7 +888,7 @@ def prefix_with_github_url(suffix_str: str) -> str:
887888
returnf"https://github.com/{suffix_str}"
888889

889890

890-
defmerge_on_green(pr_num:int,repo:GitRepo,dry_run:bool=False,timeout_minutes:int=400)->None:
891+
defmerge_on_green(pr_num:int,repo:GitRepo,dry_run:bool=False,timeout_minutes:int=400,all_green:bool=False)->None:
891892
repo=GitRepo(get_git_repo_dir(),get_git_remote_name())
892893
org,project=repo.gh_owner_and_name()
893894
start_time=time.time()
@@ -897,10 +898,25 @@ def merge_on_green(pr_num: int, repo: GitRepo, dry_run: bool = False, timeout_mi
897898
current_time=time.time()
898899
elapsed_time=current_time-start_time
899900

900-
901901
pr=GitHubPR(org,project,pr_num)
902902
try:
903-
returnpr.merge_into(repo,dry_run=dry_run)
903+
ifall_green:
904+
checks=pr.get_checkrun_conclusions()
905+
pending_checks= []
906+
failed_checks= []
907+
forcheckinchecks:
908+
ifchecks[check]isNone:
909+
pending_checks.append(check)
910+
elifchecks[check]!='SUCCESS':
911+
failed_checks.append(check)
912+
iflen(failed_checks)>0:
913+
raiseRuntimeError(f"Failed to merge due to failing checks,{','.join(failed_checks)}")
914+
iflen(pending_checks)>0:
915+
reject_reason=f"Refusing to merge as mandatory check(s){','.join(pending_checks)} are missing"
916+
raiseMandatoryChecksMissingError(reject_reason)
917+
pr.merge_into(repo,dry_run=dry_run)
918+
else:
919+
pr.merge_into(repo,dry_run=dry_run)
904920
exceptMandatoryChecksMissingErrorasex:
905921
last_exception=str(ex)
906922
print(f"Merged failed due to:{ex}. Retrying in 60 seconds.")
@@ -942,9 +958,9 @@ def handle_exception(e: Exception, msg: str = "Merge failed") -> None:
942958
gh_post_comment(org,project,args.pr_num,"Cross-repo ghstack merges are not supported",dry_run=args.dry_run)
943959
return
944960

945-
ifargs.on_green:
961+
ifargs.on_greenorargs._all_green:
946962
try:
947-
merge_on_green(args.pr_num,repo,dry_run=args.dry_run)
963+
merge_on_green(args.pr_num,repo,dry_run=args.dry_run,all_green=args.all_green)
948964
exceptExceptionase:
949965
handle_exception(e)
950966
else:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp