Skip to content
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Blame information is added to the property bag of each `result` object for which
...
"properties": {
"blame": {
"commit": "1234567890abcdef1234567890abcdef12345678",
"author": "aperson",
"author-mail": "<aperson@acompany.com>",
"author-time": "1350899798",
Expand Down Expand Up @@ -740,6 +741,7 @@ For commonly used properties the following shortcuts are defined:
| -------- | -------- |
| author | properties.blame.author |
| author-mail | properties.blame.author-mail |
| commit | properties.blame.commit |
| committer | properties.blame.committer |
| committer-mail | properties.blame.committer-mail |
| location | locations[*].physicalLocation.artifactLocation.uri |
Expand Down
4 changes: 3 additions & 1 deletion sarif/operations/blame_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ def _enhance_with_blame(
if line_no in blame_info["line_to_commit"]:
commit_hash = blame_info["line_to_commit"][line_no]
commit = blame_info["commits"][commit_hash]
# Add commit hash to the blame information
commit_with_hash = {"commit": commit_hash, **commit}
# Add blame information to the SARIF Property Bag of the result
result.setdefault("properties", {})["blame"] = commit
result.setdefault("properties", {})["blame"] = commit_with_hash
blame_info_count += 1
print(f"Found blame information for {blame_info_count} of {item_count} results")

Expand Down
2 changes: 2 additions & 0 deletions tests/ops/blame/test_blame.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def run_git_blame(blame_repo_path: str, blame_file_path: str) -> List[bytes]:

expected_blame_properties = {
"blame": {
"commit": "f9db03438aba52affc5c3fcdb619afa620ad603a",
"author": "Taylor Developer",
"author-mail": "<taylor@developer.com>",
"author-time": "1699272533",
Expand Down Expand Up @@ -200,6 +201,7 @@ def run_git_blame(blame_repo_path: str, blame_file_path: str) -> List[bytes]:

expected_blame_properties = {
"blame": {
"commit": "f9db03438aba52affc5c3fcdb619afa620ad603a",
"author": "Taylor Developer",
"author-mail": "<taylor@developer.com>",
"author-time": "1699272533",
Expand Down