remove dry run, add submit param

This commit is contained in:
David Lord 2025-01-13 10:54:04 -08:00
parent 72da5d998f
commit 1a6daf27f5
No known key found for this signature in database
GPG key ID: 43368A7AA8CC5926
5 changed files with 7 additions and 9 deletions

View file

@ -52,7 +52,7 @@ class Repo:
raise NotImplementedError raise NotImplementedError
def submit_if_needed(self) -> None: def submit_if_needed(self) -> None:
if self.needs_submit(): if self.script.enable_submit and self.needs_submit():
self.submit() self.submit()
else: else:
click.secho("skipping submit", fg="yellow") click.secho("skipping submit", fg="yellow")

View file

@ -48,7 +48,7 @@ class GitRepo(Repo):
def submit(self) -> None: def submit(self) -> None:
self.git_cmd("switch", self.script.target) self.git_cmd("switch", self.script.target)
self.git_cmd("merge", "--ff-only", self.script.branch) self.git_cmd("merge", "--ff-only", self.script.branch)
self.git_cmd("push", "--dry-run") self.git_cmd("push")
def add_files( def add_files(
self, *items: str | Path, update: bool = False, all: bool = False self, *items: str | Path, update: bool = False, all: bool = False

View file

@ -49,13 +49,10 @@ class GitHubRepo(GitRepo):
super().submit() super().submit()
return return
self.git_cmd( self.git_cmd("push", "--set-upstream", "origin", self.script.branch)
"push", "--dry-run", "--set-upstream", "origin", self.script.branch
)
self.gh_cmd( self.gh_cmd(
"pr", "pr",
"create", "create",
"--dry-run",
"--base", "--base",
self.script.target, self.script.target,
"--title", "--title",

View file

@ -18,7 +18,7 @@ class Script[RepoType: Repo]:
title: str title: str
body: str body: str
def __init__(self) -> None: def __init__(self, *, submit: bool = False) -> None:
source_file = inspect.getsourcefile(self.__class__) source_file = inspect.getsourcefile(self.__class__)
if source_file is None: if source_file is None:
@ -38,6 +38,7 @@ class Script[RepoType: Repo]:
ignore.write_text("*\n") ignore.write_text("*\n")
self.body = wrap_text(self.body, width=72) self.body = wrap_text(self.body, width=72)
self.enable_submit = submit
def render_template(self, name: str, /, **kwargs: t.Any) -> str: def render_template(self, name: str, /, **kwargs: t.Any) -> str:
return self.jinja_env.get_template(name).render(**kwargs) return self.jinja_env.get_template(name).render(**kwargs)

View file

@ -6,8 +6,8 @@ from .base import Script
class GitHubScript(Script[GitHubRepo]): class GitHubScript(Script[GitHubRepo]):
def __init__(self, orgs: list[str] | None = None) -> None: def __init__(self, *, submit: bool = True, orgs: list[str] | None = None) -> None:
super().__init__() super().__init__(submit=submit)
if orgs is not None: if orgs is not None:
self.orgs = orgs self.orgs = orgs