From 2457ae86826170cda6aaed8419b310346011602c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 29 Aug 2025 17:36:51 +0000 Subject: [PATCH 1/2] Initial plan From 67941b90ae7008876cfb106e82d3afbaffb21abf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 29 Aug 2025 17:46:02 +0000 Subject: [PATCH 2/2] Expose commit hash in sarif blame output - Add commit hash as "commit" field in blame properties - Update tests to expect commit hash in output - Update README documentation with new commit field - Add commit shortcut to filtering table - Verify functionality with manual testing Co-authored-by: gramster <2762632+gramster@users.noreply.github.com> --- README.md | 2 ++ sarif/operations/blame_op.py | 4 +++- tests/ops/blame/test_blame.py | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) 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",