Skip to content

Commit

Permalink
#162 Cleanup Code
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-Base committed Jul 13, 2024
1 parent d42e2ec commit 31ae59d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 4 additions & 2 deletions pygount/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import pygount.lexers
import pygount.xmldialect
from pygount.common import deprecated, mapped_repr
from pygount.git_storage import _GIT_REPO_REGEX, GitStorage, git_remote_url_and_revision_if_any
from pygount.git_storage import GitStorage, git_remote_url_and_revision_if_any

GIT_REPO_REGEX = re.compile(r"^(https?://|git@)")

# Attempt to import chardet.
try:
Expand Down Expand Up @@ -624,7 +626,7 @@ def _source_paths_and_groups_to_analyze(self, source_patterns_to_analyze) -> Lis
# TODO#113: Find a way to exclude the ugly temp folder from the source path.
result.extend(self._paths_and_group_to_analyze(git_storage.temp_folder))
else:
git_url_match = re.match(_GIT_REPO_REGEX, source_pattern_to_analyze)
git_url_match = re.match(GIT_REPO_REGEX, source_pattern_to_analyze)
if git_url_match is not None:
raise pygount.Error(
'URL to git repository must end with ".git", for example '
Expand Down
2 changes: 0 additions & 2 deletions pygount/git_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
r"(?P<remote_url>((git|ssh|http(s)?)|(git@[\w.-]+))(:(//)?)([\w.@:/\-~]+)(\.git))(/)?(?P<revision>[\w./\-]+)?"
)

_GIT_REPO_REGEX = re.compile(r"^(https?://|git@)")


def git_remote_url_and_revision_if_any(git_url: str) -> Tuple[Optional[str], Optional[str]]:
assert git_url is not None
Expand Down
10 changes: 5 additions & 5 deletions tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def test_can_skip_dot_folder(self):
scanned_names = [os.path.basename(source_path) for source_path, _ in scanner.source_paths()]
assert scanned_names == [name_to_include]

def test_validate_invalid_git_error(self):
testcases = [["https://github.com/roskakori/pygount/"], ["[email protected]:roskakori/pygount"]]
for testcase in testcases:
with analysis.SourceScanner(testcase) as scanner, self.assertRaises(PygountError):
_ = list(scanner.source_paths())
def test_fails_on_non_repo_url(self):
non_repo_urls = [["https://github.com/roskakori/pygount/"], ["[email protected]:roskakori/pygount"]]
for non_repo_url in non_repo_urls:
with analysis.SourceScanner(non_repo_url) as scanner, pytest.raises(PygountError):
next(scanner.source_paths())

def test_can_find_python_files_in_dot(self):
scanner = analysis.SourceScanner(["."], "py")
Expand Down

0 comments on commit 31ae59d

Please sign in to comment.