mirror of
https://github.com/davidism/modify-repos.git
synced 2025-07-07 19:35:34 +00:00
remove dry run, add submit param
This commit is contained in:
parent
72da5d998f
commit
1a6daf27f5
5 changed files with 7 additions and 9 deletions
|
@ -52,7 +52,7 @@ class Repo:
|
|||
raise NotImplementedError
|
||||
|
||||
def submit_if_needed(self) -> None:
|
||||
if self.needs_submit():
|
||||
if self.script.enable_submit and self.needs_submit():
|
||||
self.submit()
|
||||
else:
|
||||
click.secho("skipping submit", fg="yellow")
|
||||
|
|
|
@ -48,7 +48,7 @@ class GitRepo(Repo):
|
|||
def submit(self) -> None:
|
||||
self.git_cmd("switch", self.script.target)
|
||||
self.git_cmd("merge", "--ff-only", self.script.branch)
|
||||
self.git_cmd("push", "--dry-run")
|
||||
self.git_cmd("push")
|
||||
|
||||
def add_files(
|
||||
self, *items: str | Path, update: bool = False, all: bool = False
|
||||
|
|
|
@ -49,13 +49,10 @@ class GitHubRepo(GitRepo):
|
|||
super().submit()
|
||||
return
|
||||
|
||||
self.git_cmd(
|
||||
"push", "--dry-run", "--set-upstream", "origin", self.script.branch
|
||||
)
|
||||
self.git_cmd("push", "--set-upstream", "origin", self.script.branch)
|
||||
self.gh_cmd(
|
||||
"pr",
|
||||
"create",
|
||||
"--dry-run",
|
||||
"--base",
|
||||
self.script.target,
|
||||
"--title",
|
||||
|
|
|
@ -18,7 +18,7 @@ class Script[RepoType: Repo]:
|
|||
title: str
|
||||
body: str
|
||||
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, *, submit: bool = False) -> None:
|
||||
source_file = inspect.getsourcefile(self.__class__)
|
||||
|
||||
if source_file is None:
|
||||
|
@ -38,6 +38,7 @@ class Script[RepoType: Repo]:
|
|||
ignore.write_text("*\n")
|
||||
|
||||
self.body = wrap_text(self.body, width=72)
|
||||
self.enable_submit = submit
|
||||
|
||||
def render_template(self, name: str, /, **kwargs: t.Any) -> str:
|
||||
return self.jinja_env.get_template(name).render(**kwargs)
|
||||
|
|
|
@ -6,8 +6,8 @@ from .base import Script
|
|||
|
||||
|
||||
class GitHubScript(Script[GitHubRepo]):
|
||||
def __init__(self, orgs: list[str] | None = None) -> None:
|
||||
super().__init__()
|
||||
def __init__(self, *, submit: bool = True, orgs: list[str] | None = None) -> None:
|
||||
super().__init__(submit=submit)
|
||||
|
||||
if orgs is not None:
|
||||
self.orgs = orgs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue