Skip to content

Commit 09ede0b

Browse files
- cleanup log statements shown in the smartfix run
1 parent 0cc7616 commit 09ede0b

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/git_handler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ def get_issue_comments(issue_number: int, author: str = None) -> List[dict]:
927927
List[dict]: A list of comment data dictionaries or empty list if no comments or error
928928
"""
929929
author_log = f"and author: {author}" if author else ""
930-
log(f"Getting comments for issue #{issue_number} {author_log}")
930+
debug_log(f"Getting comments for issue #{issue_number} {author_log}")
931931
gh_env = get_gh_env()
932932
author_filter = f"| map(select(.author.login == \"{author}\")) " if author else ""
933933
jq_filter = f'.comments {author_filter}| sort_by(.createdAt) | reverse'
@@ -1095,7 +1095,7 @@ def get_claude_workflow_run_id() -> int:
10951095
Returns:
10961096
int: The workflow run ID if found, or None if no in-progress runs are found
10971097
"""
1098-
log("Getting in-progress Claude workflow run ID")
1098+
debug_log("Getting in-progress Claude workflow run ID")
10991099

11001100
gh_env = get_gh_env()
11011101
jq_filter = 'map(select(.event == "issues" or .event == "issue_comment") | select(.status == "in_progress") | select(.conclusion != "skipped")) | sort_by(.createdAt) | reverse | .[0]'
@@ -1131,7 +1131,7 @@ def get_claude_workflow_run_id() -> int:
11311131

11321132
if workflow_run_id is not None:
11331133
workflow_run_id = int(workflow_run_id)
1134-
log(f"Found in-progress Claude workflow run ID: {workflow_run_id}")
1134+
debug_log(f"Found in-progress Claude workflow run ID: {workflow_run_id}")
11351135
return workflow_run_id
11361136
else:
11371137
debug_log("No databaseId found in workflow run data")
@@ -1197,7 +1197,7 @@ def create_claude_pr(title: str, body: str, base_branch: str, head_branch: str)
11971197
# Run the command and capture the output (PR URL)
11981198
pr_url = run_command(pr_command, env=gh_env, check=True)
11991199
if pr_url:
1200-
log(f"Successfully created Claude PR: {pr_url}")
1200+
debug_log(f"Successfully created Claude PR: {pr_url}")
12011201
return pr_url.strip() if pr_url else ""
12021202

12031203
except Exception as e:

test/test_git_handler.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ def test_get_issue_comments_success(self, mock_log, mock_debug_log, mock_get_gh_
10031003
self.assertIn('author.login == "claude"', command[jq_index])
10041004
self.assertIn('sort_by(.createdAt) | reverse', command[jq_index])
10051005

1006-
mock_log.assert_any_call("Getting comments for issue #94 and author: claude")
1006+
mock_debug_log.assert_any_call("Getting comments for issue #94 and author: claude")
10071007
mock_debug_log.assert_any_call("Found 1 comments on issue #94")
10081008

10091009
@patch('src.git_handler.run_command')
@@ -1032,12 +1032,13 @@ def test_get_issue_comments_no_comments(self, mock_log, mock_debug_log, mock_get
10321032
# Assert
10331033
self.assertEqual(result, [])
10341034
mock_debug_log.assert_any_call(f"No comments found for issue #{issue_number}")
1035-
mock_log.assert_any_call(f"Getting comments for issue #{issue_number} and author: claude")
1035+
mock_debug_log.assert_any_call(f"Getting comments for issue #{issue_number} and author: claude")
10361036

10371037
@patch('src.git_handler.run_command')
10381038
@patch('src.git_handler.get_gh_env')
1039+
@patch('src.git_handler.debug_log')
10391040
@patch('src.git_handler.log')
1040-
def test_get_issue_comments_json_error(self, mock_log, mock_get_gh_env, mock_run_command):
1041+
def test_get_issue_comments_json_error(self, mock_log, mock_debug_log, mock_get_gh_env, mock_run_command):
10411042
"""Test getting comments from an issue when JSON parsing error occurs"""
10421043
# Setup
10431044
issue_number = 42
@@ -1055,7 +1056,7 @@ def test_get_issue_comments_json_error(self, mock_log, mock_get_gh_env, mock_run
10551056
# Assert
10561057
self.assertEqual(result, [])
10571058
mock_run_command.assert_called_once()
1058-
mock_log.assert_any_call(f"Getting comments for issue #{issue_number} and author: claude")
1059+
mock_debug_log.assert_any_call(f"Getting comments for issue #{issue_number} and author: claude")
10591060
# Use assertIn rather than assert_any_call to check for partial match
10601061
# since the actual error message includes JSON exception details
10611062
log_calls = [call[0][0] for call in mock_log.call_args_list if call[1].get('is_error', False)]
@@ -1064,8 +1065,9 @@ def test_get_issue_comments_json_error(self, mock_log, mock_get_gh_env, mock_run
10641065

10651066
@patch('src.git_handler.run_command')
10661067
@patch('src.git_handler.get_gh_env')
1068+
@patch('src.git_handler.debug_log')
10671069
@patch('src.git_handler.log')
1068-
def test_get_issue_comments_exception(self, mock_log, mock_get_gh_env, mock_run_command):
1070+
def test_get_issue_comments_exception(self, mock_log, mock_debug_log, mock_get_gh_env, mock_run_command):
10691071
"""Test getting comments from an issue when an exception occurs"""
10701072
# Setup
10711073
issue_number = 42
@@ -1083,7 +1085,7 @@ def test_get_issue_comments_exception(self, mock_log, mock_get_gh_env, mock_run_
10831085
# Assert
10841086
self.assertEqual(result, [])
10851087
mock_run_command.assert_called_once()
1086-
mock_log.assert_any_call(f"Getting comments for issue #{issue_number} and author: claude")
1088+
mock_debug_log.assert_any_call(f"Getting comments for issue #{issue_number} and author: claude")
10871089
mock_log.assert_any_call(f"Error getting comments for issue #{issue_number}: Command failed", is_error=True)
10881090

10891091
@patch('src.git_handler.run_command')
@@ -1186,8 +1188,8 @@ def test_get_claude_workflow_run_id_success(self, mock_config, mock_debug_log, m
11861188
self.assertEqual(command[command.index("--jq") + 1], 'map(select(.event == "issues" or .event == "issue_comment") | select(.status == "in_progress") | select(.conclusion != "skipped")) | sort_by(.createdAt) | reverse | .[0]')
11871189

11881190

1189-
mock_log.assert_any_call("Getting in-progress Claude workflow run ID")
1190-
mock_log.assert_any_call(f"Found in-progress Claude workflow run ID: 12345678")
1191+
mock_debug_log.assert_any_call("Getting in-progress Claude workflow run ID")
1192+
mock_debug_log.assert_any_call(f"Found in-progress Claude workflow run ID: 12345678")
11911193

11921194
@patch('src.git_handler.run_command')
11931195
@patch('src.git_handler.get_gh_env')
@@ -1326,7 +1328,7 @@ def success_run_command_side_effect(*args, **kwargs):
13261328

13271329
# Verify appropriate logs were created
13281330
mock_log.assert_any_call(f"Creating Claude PR with title: '{title}'")
1329-
mock_log.assert_any_call("Successfully created Claude PR: https://github.com/mock/repo/pull/123\n")
1331+
mock_debug_log.assert_any_call("Successfully created Claude PR: https://github.com/mock/repo/pull/123\n")
13301332

13311333
@patch('src.git_handler.run_command')
13321334
@patch('src.git_handler.get_gh_env')

0 commit comments

Comments
 (0)