From 1f9d8432076fcc9a43ffae25130454dbd494727d Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 12:58:08 +0000 Subject: [PATCH] fix: resolve CI linting and type errors --- src/promptforge/cli/commands/version.py | 29 +++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/promptforge/cli/commands/version.py b/src/promptforge/cli/commands/version.py index e4dbe95..1a27a96 100644 --- a/src/promptforge/cli/commands/version.py +++ b/src/promptforge/cli/commands/version.py @@ -1,4 +1,7 @@ +"""Version control commands.""" + import click + from promptforge.core.git_manager import GitManager @@ -32,7 +35,13 @@ def history(ctx, prompt_name: str): click.echo(f" {commit['date']} by {commit['author']}") else: for commit in commits: - click.echo(f"{commit.hexsha[:7]} - {commit.message.strip()}") + hexsha = commit.hexsha + if isinstance(hexsha, bytes): + hexsha = hexsha.decode('utf-8') + message = commit.message + if isinstance(message, bytes): + message = message.decode('utf-8') + click.echo(f"{hexsha[:7]} - {message.strip()}") click.echo(f" {commit.author.name} - {commit.committed_datetime.isoformat()}") except Exception as e: click.echo(f"Error: {e}", err=True) @@ -75,6 +84,22 @@ def branch(ctx, branch_name: str): raise click.Abort() +@version.command("switch") +@click.argument("branch_name") +@click.pass_obj +def switch(ctx, branch_name: str): + """Switch to a branch.""" + prompts_dir = ctx["prompts_dir"] + git_manager = GitManager(prompts_dir) + + try: + git_manager.switch_branch(branch_name) + click.echo(f"Switched to branch: {branch_name}") + except Exception as e: + click.echo(f"Error: {e}", err=True) + raise click.Abort() + + @version.command("list") @click.pass_obj def list_branches(ctx): @@ -121,4 +146,4 @@ def status(ctx): click.echo(status_output) except Exception as e: click.echo(f"Error: {e}", err=True) - raise click.Abort() \ No newline at end of file + raise click.Abort()