Skip to content

Commit f61ed02

Browse files
committed
Replace repo_reset with .cruft.json checkout
Resetting the repository if no dependencies are changed undoes any applied cruft updates
1 parent f5e42d6 commit f61ed02

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

cookie_python/manage/repo.py

-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ def run(
9797
kwargs.setdefault("cwd", self.clone_path)
9898
return subprocess.run(*popenargs, check=check, **kwargs)
9999

100-
def reset(self) -> None:
101-
self.run(["git", "checkout", "--", "."], check=True)
102-
103100
def shell(self) -> None:
104101
if sys.__stdin__.isatty():
105102
self.logger.info('Starting shell. Run "exit 1" to abort.')

cookie_python/manage/update.py

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
import os
2-
from functools import wraps
32
from pathlib import Path
4-
from typing import Any, Callable, Optional
3+
from typing import Optional
54

65
from .repo import RepoSandbox
76

87

9-
def repo_reset(
10-
f: Callable[[RepoSandbox], Optional[Any]]
11-
) -> Callable[..., Any]:
12-
@wraps(f)
13-
def _inner(repo: RepoSandbox) -> Optional[Any]:
14-
result = f(repo)
15-
if result is None:
16-
repo.reset()
17-
return result
18-
19-
return _inner
8+
def reset_cruft_json(repo: RepoSandbox) -> None:
9+
repo.run(
10+
["git", "checkout", "--", ".cruft.json"],
11+
capture_output=True,
12+
check=False,
13+
)
2014

2115

22-
@repo_reset
2316
def update_cruft(repo: RepoSandbox) -> Optional[str]:
2417
before_ref = repo.cruft_attr("commit")
2518
repo.run(["poetry", "env", "remove", "--all"], check=False)
@@ -41,6 +34,7 @@ def update_cruft(repo: RepoSandbox) -> Optional[str]:
4134
)
4235
if not git_status:
4336
# Skip updates with no template changes
37+
reset_cruft_json(repo)
4438
return None
4539
for try_count in range(1):
4640
rej_files = [
@@ -92,7 +86,6 @@ def update_cruft(repo: RepoSandbox) -> Optional[str]:
9286
)
9387

9488

95-
@repo_reset
9689
def update_dependencies(repo: RepoSandbox) -> Optional[str]:
9790
repo.run(["poetry", "run", "pre-commit", "autoupdate"])
9891
updates = repo.run(

0 commit comments

Comments
 (0)