Пример #1
0
def main() -> None:
    args = parse_args()
    repo = GitRepo(get_git_repo_dir(), get_git_remote_name(), debug=True)
    org, project = repo.gh_owner_and_name()

    pr = GitHubPR(org, project, args.pr_num)
    onto_branch = args.branch if args.branch else pr.default_branch()

    msg = "@pytorchbot successfully started a rebase job."
    msg += f" Check the current status [here]({os.getenv('GH_RUN_URL')})"
    gh_post_comment(org, project, args.pr_num, msg, dry_run=args.dry_run)

    if pr.is_closed():
        gh_post_comment(org,
                        project,
                        args.pr_num,
                        f"PR #{args.pr_num} is closed, won't rebase",
                        dry_run=args.dry_run)
        return

    try:
        if pr.is_ghstack_pr():
            rebase_ghstack_onto(pr, repo, onto_branch, dry_run=args.dry_run)
            return
        rebase_onto(pr, repo, onto_branch, dry_run=args.dry_run)
    except Exception as e:
        msg = f"Rebase failed due to {e}"
        run_url = os.getenv("GH_RUN_URL")
        if run_url is not None:
            msg += f"\nRaised by {run_url}"
        gh_post_comment(org, project, args.pr_num, msg, dry_run=args.dry_run)
Пример #2
0
def main() -> None:
    args = parse_args()
    repo = GitRepo(get_git_repo_dir(), get_git_remote_name(), debug=True)
    org, project = repo.gh_owner_and_name()

    pr = GitHubPR(org, project, args.pr_num)

    if pr.is_closed():
        gh_post_comment(org,
                        project,
                        args.pr_num,
                        f"PR #{args.pr_num} is closed, won't rebase",
                        dry_run=args.dry_run)
        return

    try:
        if pr.is_ghstack_pr():
            rebase_ghstack_onto(pr,
                                repo,
                                dry_run=args.dry_run,
                                stable=args.stable)
            return
        rebase_onto(pr, repo, dry_run=args.dry_run, stable=args.stable)
    except Exception as e:
        msg = f"Rebase failed due to {e}"
        run_url = os.getenv("GH_RUN_URL")
        if run_url is not None:
            msg += f"\nRaised by {run_url}"
        gh_post_comment(org, project, args.pr_num, msg, dry_run=args.dry_run)