Skip to content

Commit

Permalink
chore: fixed issues with grade result prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Jul 16, 2024
1 parent fc63710 commit bf32ecc
Show file tree
Hide file tree
Showing 16 changed files with 209 additions and 370 deletions.
3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/ruff.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/All_Tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions .idea/runConfigurations/test_grade_commit.xml

This file was deleted.

26 changes: 0 additions & 26 deletions .idea/runConfigurations/test_integration.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
- repo: https://github.com/jsh9/pydoclint
rev: 0.5.4
rev: 0.5.5
hooks:
- id: pydoclint
args: [--style=google, --check-return-types=False, --arg-type-hints-in-docstring=False]
Expand Down
60 changes: 42 additions & 18 deletions gitmind/cli/commands/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

from gitmind.cli._utils import debug_echo, get_or_set_cli_context
from gitmind.prompts import DescribeCommitHandler
from gitmind.utils.commit import extract_commit_data, get_commit
from gitmind.prompts.describe_commit import CommitDescriptionResult
from gitmind.prompts.grade_commit import CommitGradingResult, GradeCommitHandler
from gitmind.utils.commit import extract_commit_data
from gitmind.utils.sync import run_as_sync


Expand All @@ -14,24 +16,39 @@ def commit() -> None:
"""Commit commands."""


@commit.command()
@option("--commit-hash", required=True, type=str)
@pass_context
@run_as_sync
async def grade(ctx: Context, commit_hash: str) -> None:
"""Grade a commit."""
async def handle_describe(ctx: Context, commit_hash: str) -> CommitDescriptionResult:
"""Describe a commit."""
cli_ctx = get_or_set_cli_context(ctx)
cli_ctx["commit_hash"] = commit_hash
commit = get_commit(repo=cli_ctx["repo"], commit_hex=commit_hash)
echo(f"Commit {commit_hash}: {commit.message}")

commit_statistics, commit_metadata, diff = extract_commit_data(repo=cli_ctx["repo"], commit_hex=commit_hash)
debug_echo(
cli_ctx,
f"Retrieved commit {commit_hash}: {commit_metadata["message"]}\n\ncommit_data: {dumps(commit_statistics, indent=2)}",
)
handler = DescribeCommitHandler(
client=cli_ctx["settings"].llm_client,
)
description = await handler(
statistics=commit_statistics,
metadata=commit_metadata,
diff=diff,
)
cli_ctx["commit_description"] = description
return description


@commit.command()
@option("--commit-hash", required=True, type=str)
@pass_context
@run_as_sync
async def describe(ctx: Context, commit_hash: str) -> None:
def describe(ctx: Context, commit_hash: str) -> None:
"""Describe a commit."""
description_result = run_as_sync(handle_describe)(ctx, commit_hash)
echo(dumps(description_result, indent=2))


async def handle_grade(ctx: Context, commit_hash: str) -> dict[str, CommitGradingResult]:
"""Grade a commit."""
cli_ctx = get_or_set_cli_context(ctx)
cli_ctx["commit_hash"] = commit_hash

Expand All @@ -40,14 +57,21 @@ async def describe(ctx: Context, commit_hash: str) -> None:
cli_ctx,
f"Retrieved commit {commit_hash}: {commit_metadata["message"]}\n\ncommit_data: {dumps(commit_statistics, indent=2)}",
)
llm_client = cli_ctx["settings"].llm_client
handler = DescribeCommitHandler(
client=llm_client,

handler = GradeCommitHandler(
client=cli_ctx["settings"].llm_client,
)
description = await handler(
statistics=commit_statistics,

return await handler(
metadata=commit_metadata,
diff=diff,
)
cli_ctx["commit_description"] = description
echo(dumps(description, indent=2))


@commit.command()
@option("--commit-hash", required=True, type=str)
@pass_context
def grade(ctx: Context, commit_hash: str) -> None:
"""Grade a commit."""
grading_results = run_as_sync(handle_grade)(ctx, commit_hash)
echo(dumps(grading_results, indent=2))
Empty file removed gitmind/processing/__init__.py
Empty file.
45 changes: 0 additions & 45 deletions gitmind/processing/process_commit.py

This file was deleted.

Loading

0 comments on commit bf32ecc

Please sign in to comment.