Skip to content

Commit

Permalink
Revert "Default on green (pytorch#78811)"
Browse files Browse the repository at this point in the history
This reverts commit c5a0d8d.

Reverted pytorch#78811 on behalf of https://github.com/zengk95 due to This does not have force in there
  • Loading branch information
pytorchmergebot committed Jun 6, 2022
1 parent 9fca008 commit f2b56dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/scripts/trymerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def parse_args() -> Any:
from argparse import ArgumentParser
parser = ArgumentParser("Merge PR into default branch")
parser.add_argument("--dry-run", action="store_true")
parser.add_argument("--on-green", action="store_true")
parser.add_argument("--revert", action="store_true")
parser.add_argument("--force", action="store_true")
parser.add_argument("--comment-id", type=int)
Expand Down Expand Up @@ -889,7 +890,7 @@ def prefix_with_github_url(suffix_str: str) -> str:
return f"https://github.com/{suffix_str}"


def merge(pr_num: int, repo: GitRepo, dry_run: bool = False, timeout_minutes: int = 400) -> None:
def merge_on_green(pr_num: int, repo: GitRepo, dry_run: bool = False, timeout_minutes: int = 400) -> None:
repo = GitRepo(get_git_repo_dir(), get_git_remote_name())
org, project = repo.gh_owner_and_name()
start_time = time.time()
Expand Down Expand Up @@ -948,11 +949,16 @@ def handle_exception(e: Exception, msg: str = "Merge failed") -> None:
gh_post_comment(org, project, args.pr_num, "Cross-repo ghstack merges are not supported", dry_run=args.dry_run)
return

try:
merge(args.pr_num, repo, dry_run=args.dry_run)
except Exception as e:
handle_exception(e)

if args.on_green:
try:
merge_on_green(args.pr_num, repo, dry_run=args.dry_run)
except Exception as e:
handle_exception(e)
else:
try:
pr.merge_into(repo, dry_run=args.dry_run, force=args.force, comment_id=args.comment_id)
except Exception as e:
handle_exception(e)


if __name__ == "__main__":
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/trymerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
PR_NUM: ${{ github.event.client_payload.pr_num }}
GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
FORCE: ${{ github.event.client_payload.force}}
ON_GREEN: ${{ github.event.client_payload.on_green}}
COMMENT_ID: ${{ github.event.client_payload.comment_id }}
run: |
set -ex
Expand All @@ -39,6 +40,8 @@ jobs:
else
python3 .github/scripts/trymerge.py --force "${PR_NUM}"
fi
elif [ -n "${ON_GREEN}" ]; then
python3 .github/scripts/trymerge.py --on-green "${PR_NUM}"
elif [ -n "${COMMENT_ID}" ]; then
python3 .github/scripts/trymerge.py --comment-id "${COMMENT_ID}" "${PR_NUM}"
else
Expand Down

0 comments on commit f2b56dd

Please sign in to comment.