Skip to content

Commit

Permalink
Update git clone logic to fix bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
eli64s committed Dec 31, 2023
1 parent b31e797 commit 64ffcc4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "readmeai"
version = "0.4.093"
version = "0.4.094"
description = "🚀 Auto-generate beautiful README files from the terminal using GPT LLM APIs 💫"
authors = ["Eli <[email protected]>"]
license = "MIT"
Expand Down
16 changes: 7 additions & 9 deletions readmeai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import asyncio
import os
import traceback
import shutil

from readmeai.cli.options import prompt_for_custom_image
from readmeai.config.settings import (
Expand Down Expand Up @@ -99,20 +98,19 @@ async def readme_agent(conf: AppConfig, conf_helper: ConfigHelper) -> None:
conf.md.overview.format(conf.md.default),
conf.md.default,
)
logger.info(f"Total summaries generated: {len(summaries)}")

headers.build_readme_md(conf, conf_helper, dependencies, summaries)
logger.info(f"Total summaries generated: {len(summaries)}")

headers.build_readme_md(conf, conf_helper, dependencies, summaries)

logger.info(
"README-AI file generated successfully: {conf.files.output}"
)

logger.info(
"README-AI file generated successfully: {conf.files.output}"
)
except Exception as exc_info:
logger.error(
f"Exception occurred: {exc_info}\n{traceback.format_exc()}"
)
finally:
if temp_dir is not None:
shutil.rmtree(temp_dir)


def main(
Expand Down
10 changes: 3 additions & 7 deletions readmeai/services/git_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ def clone_repo_to_temp_dir(repo_path: str) -> Path:
return Path(repo_path)

try:
with tempfile.TemporaryDirectory() as temp_dir:
git.Repo.clone_from(
repo_path, temp_dir, depth=1, single_branch=True
)
new_temp_dir = Path(tempfile.mkdtemp())
shutil.copytree(temp_dir, new_temp_dir, dirs_exist_ok=True)
return new_temp_dir
temp_dir = tempfile.mkdtemp()
git.Repo.clone_from(repo_path, temp_dir, depth=1, single_branch=True)
return Path(temp_dir)

except git.GitCommandError as exc_info:
raise ValueError(f"Git clone error: {exc_info}") from exc_info
Expand Down
8 changes: 4 additions & 4 deletions tests/test_cli/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
from readmeai.cli.commands import commands


def test_commands(config):
def test_commands():
"""Test that the CLI command runs."""
runner = CliRunner()
result = runner.invoke(
commands,
[
"--repository",
config.git.repository,
"https://github.com/example/repo",
"--api-key",
"dummy-key",
],
)
assert result.exit_code == 0
assert result.exit_code == 0, f"Unexpected failure: {result.output}"


def test_commands_with_options():
Expand All @@ -36,7 +36,7 @@ def test_commands_with_options():
"0.8",
],
)
assert result.exit_code == 1
assert result.exit_code == 0


def test_commands_missing_repository():
Expand Down

0 comments on commit 64ffcc4

Please sign in to comment.