Skip to content

feat: add transformconfig#5

Open
karldreher wants to merge 8 commits intomainfrom
develop
Open

feat: add transformconfig#5
karldreher wants to merge 8 commits intomainfrom
develop

Conversation

@karldreher
Copy link
Owner

No description provided.

@karldreher karldreher requested a review from Copilot June 4, 2025 02:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new transform feature that lets users run shell commands after files are copied, including CLI support, validation, and tests.

  • Introduce TransformConfig and integrate it into ConfigFile and MixtapeMatrix.run().
  • Validate and block dangerous shell commands, update default config template.
  • Add tests and YAML fixtures for valid and dangerous transform scenarios.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/test_main.py Add tests for valid and dangerous transform commands
test/matrix.yaml Include a simple transform commands example
test/dangerous_matrix.yaml Add a dangerous command example for validation
mixtapematrix/routers/files.py Update path validator to allow default example paths
mixtapematrix/main.py Run transform.commands via subprocess.run
mixtapematrix/config.py Define TransformConfig and integrate into ConfigFile
Comments suppressed due to low confidence (5)

mixtapematrix/routers/files.py:29

  • The validator only returns path when it starts with /example/; after the existence check you need a final return path for all other valid cases.
if not os.path.exists(path):

mixtapematrix/config.py:16

  • [nitpick] Pydantic does not use attribute docstrings for schema metadata; consider using Field(..., description="…") so descriptions appear in generated schemas.
"""Source path is the directory to copy files from."""

test/test_main.py:38

  • Consider adding a test for when the transform section is omitted to ensure no commands run and no errors occur.
def test_cli():

mixtapematrix/routers/files.py:23

  • Add from pydantic import field_validator at the top of this file; otherwise the decorator will cause an ImportError.
@field_validator("path", mode="after")

test/test_main.py:25

  • [nitpick] The body of test_valid_transform is indented with 8 spaces instead of the project’s 4-space style; adjust for consistency.
        matrix = MixtapeMatrix("test/matrix.yaml")

Comment on lines +30 to +33
for command in self.config_data.transform.commands:
self.debug(f"Running command: {command}")
subprocess.run(command, shell=True, check=True)
self.debug(f"Command executed: {command}")
Copy link

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If transform is None, this will raise an AttributeError; guard this loop with if self.config_data.transform:.

Suggested change
for command in self.config_data.transform.commands:
self.debug(f"Running command: {command}")
subprocess.run(command, shell=True, check=True)
self.debug(f"Command executed: {command}")
if self.config_data.transform:
for command in self.config_data.transform.commands:
self.debug(f"Running command: {command}")
subprocess.run(command, shell=True, check=True)
self.debug(f"Command executed: {command}")

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants