Skip to content

Commit

Permalink
fix: update to use str(commit.id) as hex attribute got removed (#532)
Browse files Browse the repository at this point in the history
* fix: update to use `str(commit.id)` as hex attribute got removed

Signed-off-by: Rui Chen <[email protected]>

* Fix unit test signature

Adjust expected parameter to match new logic

* Bump PyYAML to 6.0.1

Fixes test failure for macos-latest 3.8

---------

Signed-off-by: Rui Chen <[email protected]>
Co-authored-by: Scott Bailey <[email protected]>
  • Loading branch information
chenrui333 and rscottbailey authored Jul 24, 2024
1 parent 781880c commit 44f91c0
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
84 changes: 42 additions & 42 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tartufo/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def _get_chunks(
# If a commit doesn't have a parent skip diff generation since it is the first commit
self.logger.debug(
"Skipping commit %s because it has no parents",
curr_commit.hex,
str(curr_commit.id),
)
continue
diff_hash = hashlib.md5(
Expand All @@ -860,7 +860,7 @@ def _get_chunks(

# Finally, yield the first commit to the branch
if curr_commit:
tree: pygit2.Tree = self._repo.revparse_single(curr_commit.hex).tree
tree: pygit2.Tree = self._repo.revparse_single(str(curr_commit.id)).tree
tree_diff: pygit2.Diff = tree.diff_to_tree(swap=True)
iter_diff = self._iter_diff_index(tree_diff)
for blob, file_path in iter_diff:
Expand Down
2 changes: 1 addition & 1 deletion tartufo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def extract_commit_metadata(commit: pygit2.Commit, branch_name: str) -> Dict[str
DATETIME_FORMAT
),
"commit_message": commit.message,
"commit_hash": commit.hex,
"commit_hash": str(commit.id),
"branch": branch_name,
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_git_repo_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def test_head_is_scanned_when_shallow_clone_is_found(self):
# This is all the stuff that happens for yielding the "first commit".
self.mock_repo.return_value.get.assert_called_once_with("commit-hash")
revparse = self.mock_repo.return_value.revparse_single
revparse.assert_called_once_with(mock_head.hex)
revparse.assert_called_once_with(str(mock_head.id))
tree = revparse.return_value.tree.diff_to_tree
tree.assert_called_once_with(swap=True)
self.mock_iter_diff.assert_called_with(tree.return_value)
Expand Down

0 comments on commit 44f91c0

Please sign in to comment.