Skip to content

Commit 05c5dfc

Browse files
authored
Merge pull request #2 from Arakiss/codex/find-more-potential-bugs-to-fix
Fix whitespace issues and remove debug print
2 parents b5f33f7 + a67e948 commit 05c5dfc

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

commitloom/__main__.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@
99

1010
# Load environment variables before any imports
1111
env_path = os.path.join(os.path.dirname(__file__), "..", ".env")
12-
print(f"Loading .env from: {os.path.abspath(env_path)}")
1312
load_dotenv(dotenv_path=env_path)
1413

15-
# Debug: Check if API key is loaded
16-
api_key = os.getenv("OPENAI_API_KEY")
17-
print(f"API Key loaded: {'Yes' if api_key else 'No'}")
18-
1914
from . import __version__
2015
from .cli import console
2116
from .cli.cli_handler import CommitLoom
@@ -32,14 +27,14 @@ def handle_error(error: BaseException) -> None:
3227

3328
@click.group()
3429
@click.option("-d", "--debug", is_flag=True, help="Enable debug logging")
35-
@click.option("-v", "--version", is_flag=True, callback=lambda ctx, param, value:
30+
@click.option("-v", "--version", is_flag=True, callback=lambda ctx, param, value:
3631
value and print(f"CommitLoom, version {__version__}") or exit(0) if value else None,
3732
help="Show the version and exit.")
3833
@click.pass_context
3934
def cli(ctx, debug: bool, version: bool = False) -> None:
4035
"""Create structured git commits with AI-generated messages."""
4136
ctx.ensure_object(dict)
42-
37+
4338
# Check for debug mode in config file or environment variable
4439
debug_env = os.getenv("DEBUG_MODE", "").lower() in ("true", "1", "yes")
4540
ctx.obj["DEBUG"] = debug or debug_env
@@ -52,8 +47,8 @@ def cli(ctx, debug: bool, version: bool = False) -> None:
5247
@click.option("-y", "--yes", is_flag=True, help="Skip all confirmation prompts")
5348
@click.option("-c", "--combine", is_flag=True, help="Combine all changes into a single commit")
5449
@click.option(
55-
"-m",
56-
"--model",
50+
"-m",
51+
"--model",
5752
type=str, # Permitir cualquier string
5853
help=f"Specify any OpenAI model to use (default: {config.default_model})"
5954
)
@@ -140,32 +135,32 @@ def main() -> None:
140135
debug_options = ['-d', '--debug']
141136
# These are options specific to the commit command
142137
commit_options = ['-y', '--yes', '-c', '--combine', '-m', '--model']
143-
138+
144139
# If no arguments, simply add the default commit command
145140
if len(sys.argv) == 1:
146141
sys.argv.insert(1, 'commit')
147142
cli(obj={})
148143
return
149-
144+
150145
# Check the first argument
151146
first_arg = sys.argv[1]
152-
147+
153148
# If it's already a known command, no need to modify
154149
if first_arg in known_commands:
155150
cli(obj={})
156151
return
157-
152+
158153
# If it starts with any commit-specific option, it's intended for the commit command
159154
if first_arg in commit_options:
160155
sys.argv.insert(1, 'commit')
161156
cli(obj={})
162157
return
163-
158+
164159
# If it's a global option, don't insert commit
165160
if any(first_arg == opt for opt in global_options):
166161
cli(obj={})
167162
return
168-
163+
169164
# If it's a debug option, add 'commit' after it to enable debugging for the commit command
170165
if first_arg in debug_options:
171166
# Check if there's a command after the debug flag
@@ -174,12 +169,12 @@ def main() -> None:
174169
sys.argv.insert(2, 'commit')
175170
cli(obj={})
176171
return
177-
178-
# For any other non-option argument that's not a known command,
172+
173+
# For any other non-option argument that's not a known command,
179174
# assume it's meant for the commit command
180175
if not first_arg.startswith('-'):
181176
sys.argv.insert(1, 'commit')
182-
177+
183178
cli(obj={})
184179

185180

commitloom/services/metrics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,15 @@ def get_statistics(self) -> dict[str, Any]:
271271
try:
272272
first = datetime.fromisoformat(stats["first_used_at"])
273273
last = datetime.fromisoformat(stats["last_used_at"])
274-
274+
275275
# Calculate days active (at least 1)
276276
days_active = max(1, (last.date() - first.date()).days + 1)
277277
stats["days_active"] = days_active
278278

279279
if days_active > 0:
280280
# Calculate average commits per day
281281
stats["avg_commits_per_day"] = stats["total_commits"] / days_active
282-
282+
283283
# Calculate average cost per day (ensure it's not zero)
284284
stats["avg_cost_per_day"] = stats["total_cost_in_eur"] / days_active
285285
except (ValueError, TypeError):
@@ -462,11 +462,11 @@ def _format_timedelta(td: timedelta) -> str:
462462
parts.append(f"{hours} hour{'s' if hours != 1 else ''}")
463463
if minutes > 0 or (days == 0 and hours == 0):
464464
parts.append(f"{minutes} minute{'s' if minutes != 1 else ''}")
465-
465+
466466
# Always include at least one unit (default to minutes if everything is 0)
467467
if not parts:
468468
parts.append("0 minutes")
469-
469+
470470
return " ".join(parts)
471471

472472

0 commit comments

Comments
 (0)