Lines Matching +full:repo +full:- +full:name
21 def parse_args() -> Any:
25 parser.add_argument("--dry-run", action="store_true")
26 parser.add_argument("--branch", type=str)
32 pr: GitHubPR, repo: GitRepo, onto_branch: str, dry_run: bool
33 ) -> None:
36 def_branch_fcn = f"refs/remotes/{repo.remote}/{def_branch}"
37 if onto_branch != def_branch_fcn and repo.rev_parse(
39 ) != repo.rev_parse(onto_branch):
42 msg += f"\n`@pytorchbot rebase -b {def_branch}`"
54 pr: GitHubPR, repo: GitRepo, onto_branch: str, dry_run: bool = False
55 ) -> bool:
60 repo.fetch(branch, branch)
61 repo._run_git("rebase", onto_branch, branch)
63 if repo.rev_parse(branch) == repo.rev_parse(onto_branch):
67 push_result = repo._run_git("push", "--dry-run", "-f", remote_url, refspec)
69 push_result = repo._run_git("push", "-f", remote_url, refspec)
70 if "Everything up-to-date" in push_result:
71 post_already_uptodate(pr, repo, onto_branch, dry_run)
80 + "git pull --rebase`)",
87 pr: GitHubPR, repo: GitRepo, onto_branch: str, dry_run: bool = False
88 ) -> bool:
91 [sys.executable, "-m", "ghstack", "--help"],
97 subprocess.run([sys.executable, "-m", "pip", "install", "ghstack"], check=True)
100 repo.fetch(orig_ref, orig_ref)
101 repo._run_git("rebase", onto_branch, orig_ref)
103 if repo.rev_parse(orig_ref) == repo.rev_parse(onto_branch):
107 email = repo._run_git("log", orig_ref, "--pretty=format:%ae", "-1")
108 name = repo._run_git("log", orig_ref, "--pretty=format:%an", "-1")
109 repo._run_git("config", "--global", "user.email", email)
110 repo._run_git("config", "--global", "user.name", name)
122 print("Don't know how to dry-run ghstack")
126 push_result = ghstack_result.stdout.decode("utf-8")
129 print(ghstack_result.stderr.decode("utf-8"))
134 # - Updated https://github.com/clee2000/random-testing/pull/2
135 # - Updated https://github.com/clee2000/random-testing/pull/1
140 # ghimport -s https://github.com/clee2000/random-testing/pull/2
144 # ghstack checkout https://github.com/clee2000/random-testing/pull/2
145 org, project = repo.gh_owner_and_name()
148 pr_num = int(line.split("/")[-1])
174 post_already_uptodate(pr, repo, onto_branch, dry_run)
179 def additional_rebase_failure_info(e: Exception) -> str:
185 "repo has additional permissions settings that mergebot does not qualify."
191 def git_config_guard(repo: GitRepo) -> Generator[None, None, None]:
192 """Restores user.name and user.email global properties after context is finished"""
193 user_email = repo._run_git("config", "user.email")
194 user_name = repo._run_git("config", "user.name")
199 repo._run_git("config", "--global", "user.email", user_email)
201 repo._run_git("config", "--global", "user.name", user_name)
204 def main() -> None:
206 repo = GitRepo(get_git_repo_dir(), get_git_remote_name(), debug=True)
207 org, project = repo.gh_owner_and_name()
211 onto_branch = f"refs/remotes/{repo.remote}/{onto_branch}"
213 f"https://github.com/{org}/{project}/commit/{repo.rev_parse(onto_branch)}"
232 with git_config_guard(repo):
233 rc = rebase_ghstack_onto(pr, repo, onto_branch, dry_run=args.dry_run)
235 rc = rebase_onto(pr, repo, onto_branch, dry_run=args.dry_run)