From f9f6dbefa8bf94be64c1c5b917402f5de939453f Mon Sep 17 00:00:00 2001 From: mannaandpoem <1580466765@qq.com> Date: Thu, 25 Jan 2024 10:33:46 +0800 Subject: [PATCH 1/2] Add the tar command to extract the .zip file --- tests/metagpt/test_incremental_dev.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/metagpt/test_incremental_dev.py b/tests/metagpt/test_incremental_dev.py index 7bc319ed2..1baa82a72 100644 --- a/tests/metagpt/test_incremental_dev.py +++ b/tests/metagpt/test_incremental_dev.py @@ -105,8 +105,16 @@ def log_and_check_result(result, tag_name="refine"): def get_incremental_dev_result(idea, project_name, use_review=True): project_path = TEST_DATA_PATH / "incremental_dev_project" / project_name - if project_path.exists(): - raise Exception(f"Project {project_name} not exists") + # Check if the project path exists + if not project_path.exists(): + # If the project does not exist, extract the project file + try: + # Use the tar command to extract the .zip file + subprocess.run(["tar", "-xf", f"{project_path}.zip", "-C", str(project_path.parent)], check=True) + except subprocess.CalledProcessError as e: + # If the extraction fails, throw an exception + raise Exception(f"Failed to unzip project {project_name}. Error: {e}") + check_or_create_base_tag(project_path) args = [idea, "--inc", "--project-path", project_path, "--n-round", "20"] if not use_review: @@ -146,14 +154,18 @@ def check_or_create_base_tag(project_path): logger.info("Base tag doesn't exist.") # Add and commit the current code if 'base' tag doesn't exist add_cmd = ["git", "add", "."] - commit_cmd = ["git", "commit", "-m", "Initial commit"] try: subprocess.run(add_cmd, check=True) + logger.info("Files added successfully.") + except subprocess.CalledProcessError as e: + logger.error(f"Failed to add files: {e}") + + commit_cmd = ["git", "commit", "-m", "Initial commit"] + try: subprocess.run(commit_cmd, check=True) - logger.info("Added and committed all files with the message 'Initial commit'.") - except Exception as e: - logger.error("Failed to add and commit all files.") - raise e + logger.info("Committed all files with the message 'Initial commit'.") + except subprocess.CalledProcessError as e: + logger.error(f"Failed to commit: {e.stderr}") # Add 'base' tag add_base_tag_cmd = ["git", "tag", "base"] From 0faae9368f18a27c690a92c652013578cb2dda3f Mon Sep 17 00:00:00 2001 From: mannaandpoem <1580466765@qq.com> Date: Thu, 25 Jan 2024 11:52:14 +0800 Subject: [PATCH 2/2] Add the tar command to extract the .zip file --- tests/metagpt/test_incremental_dev.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/metagpt/test_incremental_dev.py b/tests/metagpt/test_incremental_dev.py index 1baa82a72..6a26f9b83 100644 --- a/tests/metagpt/test_incremental_dev.py +++ b/tests/metagpt/test_incremental_dev.py @@ -113,7 +113,7 @@ def get_incremental_dev_result(idea, project_name, use_review=True): subprocess.run(["tar", "-xf", f"{project_path}.zip", "-C", str(project_path.parent)], check=True) except subprocess.CalledProcessError as e: # If the extraction fails, throw an exception - raise Exception(f"Failed to unzip project {project_name}. Error: {e}") + raise Exception(f"Failed to extract project {project_name}. Error: {e}") check_or_create_base_tag(project_path) args = [idea, "--inc", "--project-path", project_path, "--n-round", "20"]