Skip to content

Commit ac28931

Browse files
committed
Merge branch 'v0.2.x' of github.com:scverse/cookiecutter-scverse into v0.2.x
2 parents b663f51 + e742888 commit ac28931

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

scripts/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies = [
2323
"GitPython",
2424
"PyGitHub",
2525
"PyYAML",
26-
"pre-commit"
26+
"pre-commit", # is ran by cruft
2727
]
2828

2929
[project.optional-dependencies]

scripts/src/scverse_template_scripts/cruft_prs.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
from .backoff import retry_with_backoff
3030

3131
log = getLogger(__name__)
32-
log_dir = Path("./log")
33-
log_dir.mkdir(exist_ok=True)
3432

3533
PR_BODY_TEMPLATE = """\
3634
`cookiecutter-scverse` released [{release.tag_name}]({release.html_url}).
@@ -141,17 +139,21 @@ def get_repo_urls(gh: Github) -> Generator[str]:
141139
yield repo["url"]
142140

143141

144-
def run_cruft(cwd: Path, git_tag: str, log_name: str) -> CompletedProcess:
142+
def run_cruft(cwd: Path, *, tag_name: str, log_name: str) -> CompletedProcess:
145143
args = [
146144
sys.executable,
147145
"-m",
148146
"cruft",
149147
"update",
150-
f"--checkout={git_tag}",
148+
f"--checkout={tag_name}",
151149
"--skip-apply-ask",
152150
"--project-dir=.",
153151
]
154-
with open(log_dir / f"{log_name}.txt", "w") as log_file:
152+
153+
log_path = Path(f"./log/{log_name}.txt")
154+
log_path.parent.mkdir(exist_ok=True)
155+
156+
with log_path.open("w") as log_file:
155157
return run(args, check=True, cwd=cwd, stdout=log_file, stderr=log_file)
156158

157159

@@ -162,7 +164,13 @@ def run_cruft(cwd: Path, git_tag: str, log_name: str) -> CompletedProcess:
162164

163165

164166
def cruft_update( # noqa: PLR0913
165-
con: GitHubConnection, tag_name: str, repo: GHRepo, origin: GHRepo, path: Path, pr: PR
167+
con: GitHubConnection,
168+
pr: PR,
169+
*,
170+
tag_name: str,
171+
repo: GHRepo,
172+
origin: GHRepo,
173+
path: Path,
166174
) -> bool:
167175
clone = retry_with_backoff(
168176
lambda: Repo.clone_from(con.auth(repo.clone_url), path),
@@ -174,7 +182,7 @@ def cruft_update( # noqa: PLR0913
174182
branch = clone.create_head(pr.branch, f"{pr.repo_id}/{origin.default_branch}")
175183
branch.checkout()
176184

177-
run_cruft(path, tag_name, pr.branch)
185+
run_cruft(path, tag_name=tag_name, log_name=pr.branch)
178186

179187
if not clone.is_dirty():
180188
return False
@@ -210,7 +218,14 @@ def make_pr(con: GitHubConnection, release: GHRelease, repo_url: str) -> None:
210218
origin = con.gh.get_repo(repo_url.removeprefix("https://github.com/"))
211219
repo = get_fork(con, origin)
212220
with TemporaryDirectory() as td:
213-
updated = cruft_update(con, release.tag_name, repo, origin, Path(td), pr)
221+
updated = cruft_update(
222+
con,
223+
pr,
224+
tag_name=release.tag_name,
225+
repo=repo,
226+
origin=origin,
227+
path=Path(td),
228+
)
214229
if updated:
215230
if old_pr := next((p for p in origin.get_pulls("open") if pr.matches(p)), None):
216231
old_pr.edit(state="closed")

0 commit comments

Comments
 (0)