Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update to use str(commit.id) as hex attribute got removed #532

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading