fix: resolve CI linting and type errors
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
|
"""Version control commands."""
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
from promptforge.core.git_manager import GitManager
|
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']}")
|
click.echo(f" {commit['date']} by {commit['author']}")
|
||||||
else:
|
else:
|
||||||
for commit in commits:
|
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()}")
|
click.echo(f" {commit.author.name} - {commit.committed_datetime.isoformat()}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f"Error: {e}", err=True)
|
click.echo(f"Error: {e}", err=True)
|
||||||
@@ -75,6 +84,22 @@ def branch(ctx, branch_name: str):
|
|||||||
raise click.Abort()
|
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")
|
@version.command("list")
|
||||||
@click.pass_obj
|
@click.pass_obj
|
||||||
def list_branches(ctx):
|
def list_branches(ctx):
|
||||||
@@ -121,4 +146,4 @@ def status(ctx):
|
|||||||
click.echo(status_output)
|
click.echo(status_output)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
click.echo(f"Error: {e}", err=True)
|
click.echo(f"Error: {e}", err=True)
|
||||||
raise click.Abort()
|
raise click.Abort()
|
||||||
|
|||||||
Reference in New Issue
Block a user