Skip to content

Commit 1996149

Browse files
[primer] Better error message when the local directory are dirty
1 parent 726cf73 commit 1996149

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pylint/testutils/_primer/package_to_lint.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@
1515
PRIMER_DIRECTORY_PATH = Path("tests") / ".pylint_primer_tests"
1616

1717

18+
class DirtyPrimerDirectoryException(Exception):
19+
"""We can't pull if there's local changes."""
20+
21+
def __init__(self, path: Path | str):
22+
super().__init__(
23+
rf"""
24+
25+
/!\ Can't pull /!\
26+
27+
In order for the prepare command to be able to pull please cleanup your local repo:
28+
cd {path}
29+
git diff
30+
"""
31+
)
32+
33+
1834
class PackageToLint:
1935
"""Represents data about a package to be tested during primer tests."""
2036

@@ -120,6 +136,8 @@ def _pull_repository(self) -> str:
120136
)
121137
try:
122138
repo = Repo(self.clone_directory)
139+
if repo.is_dirty():
140+
raise DirtyPrimerDirectoryException(self.clone_directory)
123141
origin = repo.remotes.origin
124142
origin.pull()
125143
except GitCommandError as e:

0 commit comments

Comments
 (0)