Skip to content

Commit

Permalink
Revert _iter_diff_index rename
Browse files Browse the repository at this point in the history
  • Loading branch information
sushantmimani committed Oct 21, 2021
1 parent 3b2be13 commit 22b4a92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tartufo.scanner
.. automodule:: tartufo.scanner
:inherited-members:
:members:
:private-members: _iter_diff
:private-members: _iter_diff_index
:show-inheritance:
:undoc-members:

Expand Down
8 changes: 4 additions & 4 deletions tartufo/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def __init__(self, global_options: types.GlobalOptions, repo_path: str) -> None:
super().__init__(global_options)
self._repo = self.load_repo(self.repo_path)

def _iter_diff(self, diff: pygit2.Diff) -> Generator[Tuple[str, str], None, None]:
def _iter_diff_index(self, diff: pygit2.Diff) -> Generator[Tuple[str, str], None, None]:
"""Iterate over a "diff index", yielding the individual file changes.
A "diff index" is essentially analogous to a single commit in the git
Expand Down Expand Up @@ -648,7 +648,7 @@ def chunks(self) -> Generator[types.Chunk, None, None]:
if diff_hash in already_searched:
continue
already_searched.add(diff_hash)
for blob, file_path in self._iter_diff(diff):
for blob, file_path in self._iter_diff_index(diff):
yield types.Chunk(
blob,
file_path,
Expand All @@ -659,7 +659,7 @@ def chunks(self) -> Generator[types.Chunk, None, None]:
if curr_commit:
tree: pygit2.Tree = self._repo.revparse_single(curr_commit.hex).tree
tree_diff: pygit2.Diff = tree.diff_to_tree()
iter_diff = self._iter_diff(tree_diff)
iter_diff = self._iter_diff_index(tree_diff)
for blob, file_path in iter_diff:
yield types.Chunk(
blob,
Expand Down Expand Up @@ -693,7 +693,7 @@ def chunks(self):
:rtype: Generator[Chunk, None, None]
"""
diff_index = self._repo.diff("HEAD")
for blob, file_path in self._iter_diff(diff_index):
for blob, file_path in self._iter_diff_index(diff_index):
yield types.Chunk(blob, file_path, {})


Expand Down
12 changes: 6 additions & 6 deletions tests/test_git_repo_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_explicit_exception_is_raised_if_fetch_fails(
for _ in test_scanner.chunks:
pass

@mock.patch("tartufo.scanner.GitScanner._iter_diff")
@mock.patch("tartufo.scanner.GitScanner._iter_diff_index")
@mock.patch("pygit2.Repository")
def test_all_branches_are_scanned_for_commits(
self, mock_repo: mock.MagicMock, mock_iter_diff: mock.MagicMock
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_all_branches_are_scanned_for_commits(
)
)

@mock.patch("tartufo.scanner.GitRepoScanner._iter_diff")
@mock.patch("tartufo.scanner.GitRepoScanner._iter_diff_index")
@mock.patch("pygit2.Repository")
def test_all_commits_are_scanned_for_files(
self,
Expand Down Expand Up @@ -277,7 +277,7 @@ def test_all_commits_are_scanned_for_files(
)
)

@mock.patch("tartufo.scanner.GitRepoScanner._iter_diff")
@mock.patch("tartufo.scanner.GitRepoScanner._iter_diff_index")
@mock.patch("tartufo.util.extract_commit_metadata")
@mock.patch("pygit2.Repository")
def test_all_files_are_yielded_as_chunks(
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_binary_files_are_skipped(self):
test_scanner = scanner.GitRepoScanner(
self.global_options, self.git_options, "."
)
diffs = list(test_scanner._iter_diff([mock_diff]))
diffs = list(test_scanner._iter_diff_index([mock_diff]))
self.assertEqual(diffs, [])

@mock.patch("pygit2.Repository", new=mock.MagicMock())
Expand All @@ -337,7 +337,7 @@ def test_excluded_files_are_not_scanned(self, mock_should: mock.MagicMock):
test_scanner = scanner.GitRepoScanner(
self.global_options, self.git_options, "."
)
diffs = list(test_scanner._iter_diff([mock_diff]))
diffs = list(test_scanner._iter_diff_index([mock_diff]))
self.assertEqual(diffs, [])
mock_should.assert_called_once()

Expand All @@ -360,7 +360,7 @@ def test_all_files_are_yielded(self, mock_should: mock.MagicMock):
test_scanner = scanner.GitRepoScanner(
self.global_options, self.git_options, "."
)
diffs = list(test_scanner._iter_diff([mock_diff_1, mock_diff_2]))
diffs = list(test_scanner._iter_diff_index([mock_diff_1, mock_diff_2]))
self.assertEqual(
diffs,
[
Expand Down

0 comments on commit 22b4a92

Please sign in to comment.