Skip to content

Commit e10911e

Browse files
committed
fix: critical bug fixes for v1.6.1
Bug Fixes: - Fixed duplicate logging output (messages appearing 2-3 times) - Fixed metrics JSON parsing errors on corrupted files - Fixed MyPy type errors with Response objects - Reduced verbose output from smart grouping Improvements: - Cleaner, more concise console output - Silent handling of first-run file creation - Better error handling for API responses
1 parent 0bf7ab2 commit e10911e

File tree

10 files changed

+44
-39
lines changed

10 files changed

+44
-39
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## [1.6.1] - 2025-08-21
4+
5+
### 🐛 Bug Fixes
6+
- **Fixed duplicate logging**: Removed redundant logger calls causing messages to appear 2-3 times
7+
- **Fixed metrics JSON parsing**: Better handling of corrupted or missing metrics files
8+
- **Fixed MyPy type errors**: Added proper type checks for Response objects and type hints
9+
- **Reduced output verbosity**: Simplified smart grouping output to be more concise
10+
11+
### 🚀 Improvements
12+
- Cleaner console output without debug noise
13+
- Silent handling of first-run file creation
14+
- More concise smart grouping summaries
15+
- Better error handling for API responses
16+
317
## [1.6.0] - 2025-08-21
418

519
### ✨ Features

commitloom/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .core.git import GitError, GitFile, GitOperations
66
from .services.ai_service import AIService, CommitSuggestion, TokenUsage
77

8-
__version__ = "1.6.0"
8+
__version__ = "1.6.1"
99
__author__ = "Petru Arakiss"
1010
__email__ = "petruarakiss@gmail.com"
1111

commitloom/__main__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ def commit(ctx, yes: bool, combine: bool, debug: bool, smart_grouping: bool, mod
8181

8282
# Configure smart grouping
8383
loom.use_smart_grouping = smart_grouping
84-
if smart_grouping:
85-
console.print_info("Smart grouping: ENABLED (analyzing file relationships)")
86-
else:
87-
console.print_info("Smart grouping: DISABLED (using basic grouping)")
8884

8985
# Validación personalizada para modelos OpenAI
9086
if model:

commitloom/cli/cli_handler.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22
"""Main CLI handler module for CommitLoom."""
33

4-
import logging
54
import os
65
import subprocess
76
import sys
@@ -19,14 +18,8 @@
1918
env_path = os.path.join(os.path.dirname(__file__), "..", "..", ".env")
2019
load_dotenv(dotenv_path=env_path)
2120

22-
# Configure logging
23-
logging.basicConfig(
24-
level=logging.INFO,
25-
format="%(levelname)s: %(message)s",
26-
handlers=[logging.StreamHandler(sys.stdout)],
27-
)
28-
29-
logger = logging.getLogger(__name__)
21+
# Logging is configured by console module
22+
# logger = logging.getLogger(__name__)
3023

3124
# Minimum number of files to activate batch processing
3225
BATCH_THRESHOLD = 3
@@ -281,23 +274,15 @@ def _create_basic_batches(self, valid_files: list[GitFile]) -> list[list[GitFile
281274

282275
def _create_smart_batches(self, valid_files: list[GitFile]) -> list[list[GitFile]]:
283276
"""Create intelligent batches using semantic analysis."""
284-
console.print_info("Analyzing file relationships for intelligent grouping...")
285-
286277
# Use the smart grouper to analyze files
287278
file_groups = self.smart_grouper.analyze_files(valid_files)
288279

289280
if not file_groups:
290281
console.print_warning("Smart grouping produced no groups, falling back to basic grouping")
291282
return self._create_basic_batches(valid_files)
292283

293-
# Print group summary for user
294-
console.print_info(f"Created {len(file_groups)} intelligent groups:")
295-
for i, group in enumerate(file_groups, 1):
296-
console.print_info(f" Group {i}: {group.change_type.value} - {len(group.files)} files")
297-
console.print_info(f" Reason: {group.reason}")
298-
console.print_info(f" Confidence: {group.confidence:.0%}")
299-
for file in group.files:
300-
console.print_info(f" - {file.path}")
284+
# Print concise group summary
285+
console.print_info(f"Smart grouping created {len(file_groups)} groups based on file relationships")
301286

302287
# Convert FileGroup objects to lists of GitFile
303288
batches = [group.files for group in file_groups]

commitloom/cli/console.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ def set_auto_confirm(value: bool) -> None:
4141
def setup_logging(debug: bool = False):
4242
"""Configure logging with optional debug mode."""
4343
level = logging.DEBUG if debug else logging.INFO
44-
44+
45+
# Clear existing handlers to avoid duplicates
46+
logger.handlers.clear()
47+
4548
# Configure rich handler
4649
rich_handler = RichHandler(rich_tracebacks=True, markup=True, show_time=debug, show_path=debug)
4750
rich_handler.setLevel(level)
@@ -51,7 +54,7 @@ def setup_logging(debug: bool = False):
5154
logger.addHandler(rich_handler)
5255

5356
if debug:
54-
logger.debug("Debug mode enabled")
57+
console.print("[dim]Debug mode enabled[/dim]")
5558

5659

5760
def print_debug(message: str, exc_info: bool = False) -> None:
@@ -66,25 +69,21 @@ def print_debug(message: str, exc_info: bool = False) -> None:
6669

6770
def print_info(message: str) -> None:
6871
"""Print info message."""
69-
logger.info(f"ℹ️ {message}")
7072
console.print(f"\n[bold blue]ℹ️ {message}[/bold blue]")
7173

7274

7375
def print_warning(message: str) -> None:
7476
"""Print warning message."""
75-
logger.warning(f"⚠️ {message}")
7677
console.print(f"\n[bold yellow]⚠️ {message}[/bold yellow]")
7778

7879

7980
def print_error(message: str) -> None:
8081
"""Print error message."""
81-
logger.error(f"❌ {message}")
8282
console.print(f"\n[bold red]❌ {message}[/bold red]")
8383

8484

8585
def print_success(message: str) -> None:
8686
"""Print success message."""
87-
logger.info(f"✅ {message}")
8887
console.print(f"\n[bold green]✅ {message}[/bold green]")
8988

9089

commitloom/core/smart_grouping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def _extract_imports(self, file_path: str, language: str) -> list[str]:
419419
Returns:
420420
List of imported modules/files
421421
"""
422-
imports = []
422+
imports: list[str] = []
423423

424424
# For this implementation, we'll return empty list
425425
# In a real implementation, we would read the file and extract imports

commitloom/services/ai_service.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ def generate_commit_message(
251251
error_message = str(last_exception)
252252
raise ValueError(f"API Request failed: {error_message}") from last_exception
253253

254+
if response is None:
255+
raise ValueError("No response received from API")
256+
254257
if response.status_code == 400:
255258
error_data = response.json()
256259
error_message = error_data.get("error", {}).get("message", "Unknown error")

commitloom/services/metrics.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,16 @@ def _load_statistics(self) -> UsageStatistics:
8686
data = json.load(f)
8787
# Ensure valid JSON structure
8888
if not isinstance(data, dict):
89-
logger.warning("Invalid statistics file format, creating new file")
89+
logger.debug("Invalid statistics file format, resetting")
9090
return UsageStatistics()
9191
stats = UsageStatistics(**data)
9292
return stats
93-
except (json.JSONDecodeError, FileNotFoundError, KeyError) as e:
94-
logger.warning(f"Failed to load statistics, creating new file: {str(e)}")
93+
except FileNotFoundError:
94+
# Normal for first run, don't log
95+
return UsageStatistics()
96+
except (json.JSONDecodeError, KeyError) as e:
97+
# Only log for actual corruption
98+
logger.debug(f"Statistics file corrupted, resetting: {str(e)}")
9599
return UsageStatistics()
96100

97101
def _save_statistics(self) -> None:
@@ -123,10 +127,14 @@ def _save_metrics(self, metrics: CommitMetrics) -> None:
123127
with open(self._metrics_file) as f:
124128
metrics_list = json.load(f)
125129
if not isinstance(metrics_list, list):
126-
logger.warning("Invalid metrics file format, creating new file")
130+
logger.debug("Invalid metrics file format, resetting")
127131
metrics_list = []
128-
except (json.JSONDecodeError, FileNotFoundError) as e:
129-
logger.warning(f"Failed to load metrics, creating new file: {str(e)}")
132+
except FileNotFoundError:
133+
# Normal for first run, don't log
134+
metrics_list = []
135+
except json.JSONDecodeError as e:
136+
# Only log for actual corruption
137+
logger.debug(f"Metrics file corrupted, resetting: {str(e)}")
130138
metrics_list = []
131139

132140
# Add new metrics and save

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "commitloom"
3-
version = "1.6.0"
3+
version = "1.6.1"
44
description = "Weave perfect git commits with AI-powered intelligence"
55
authors = [
66
{ name = "Petru Arakiss", email = "petruarakiss@gmail.com" }

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)