diff --git a/README.md b/README.md index 0d2bc74..cd0179c 100644 --- a/README.md +++ b/README.md @@ -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": "", "author-time": "1350899798", @@ -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 | diff --git a/sarif/operations/blame_op.py b/sarif/operations/blame_op.py index 6b0d828..10a5378 100644 --- a/sarif/operations/blame_op.py +++ b/sarif/operations/blame_op.py @@ -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") diff --git a/tests/ops/blame/test_blame.py b/tests/ops/blame/test_blame.py index cf93c29..a0d2d55 100644 --- a/tests/ops/blame/test_blame.py +++ b/tests/ops/blame/test_blame.py @@ -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": "", "author-time": "1699272533", @@ -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": "", "author-time": "1699272533",