From a4abd0d24510caf16c0d4015b8e1724eab9748ab Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:44:28 +0000 Subject: [PATCH 1/2] Initial plan From 89394e97295efd99a25fcb44bee97b5799948b19 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:52:36 +0000 Subject: [PATCH 2/2] Remove --language option from rhiza init CLI command Co-authored-by: tschm <2046079+tschm@users.noreply.github.com> --- src/rhiza/cli.py | 21 +------ tests/test_commands/test_init_language.py | 75 ++++++++--------------- 2 files changed, 27 insertions(+), 69 deletions(-) diff --git a/src/rhiza/cli.py b/src/rhiza/cli.py index 6b05dce0..566ceeff 100644 --- a/src/rhiza/cli.py +++ b/src/rhiza/cli.py @@ -100,18 +100,10 @@ def init( help="Target Git hosting platform (github or gitlab). Determines which CI/CD files to include. " "If not provided, will prompt interactively.", ), - language: str = typer.Option( - "python", - "--language", - help="Programming language for the project (python, go, etc.). Defaults to 'python'.", - ), template_repository: str = typer.Option( None, "--template-repository", - help=( - "Custom template repository (format: owner/repo). " - "Defaults to 'jebel-quant/rhiza' for Python or 'jebel-quant/rhiza-go' for Go." - ), + help=("Custom template repository (format: owner/repo). Defaults to 'jebel-quant/rhiza'."), ), template_branch: str = typer.Option( None, @@ -124,24 +116,18 @@ def init( Creates a default `.rhiza/template.yml` configuration file if one doesn't exist, or validates the existing configuration. - The default template includes common project files based on the language. + The default template includes common project files. The --git-host option determines which CI/CD configuration to include: - github: includes .github folder (GitHub Actions workflows) - gitlab: includes .gitlab-ci.yml (GitLab CI configuration) - The --language option determines the project type and files created: - - python: creates pyproject.toml, src/, and Python project structure - - go: creates minimal structure (you'll need to run 'go mod init') - Examples: rhiza init - rhiza init --language go - rhiza init --language python --git-host github rhiza init --git-host gitlab + rhiza init --git-host github rhiza init --template-repository myorg/my-templates rhiza init --template-repository myorg/my-templates --template-branch develop rhiza init /path/to/project - rhiza init .. --language go """ if not init_cmd( target, @@ -149,7 +135,6 @@ def init( package_name=package_name, with_dev_dependencies=with_dev_dependencies, git_host=git_host, - language=language, template_repository=template_repository, template_branch=template_branch, ): diff --git a/tests/test_commands/test_init_language.py b/tests/test_commands/test_init_language.py index 9792d158..41a46cb5 100644 --- a/tests/test_commands/test_init_language.py +++ b/tests/test_commands/test_init_language.py @@ -1,4 +1,4 @@ -"""Tests for language-specific init functionality.""" +"""Tests for template-repository-based init functionality.""" from unittest.mock import patch @@ -7,14 +7,15 @@ from rhiza.commands.init import init -class TestInitWithLanguage: - """Tests for init command with language parameter.""" +class TestInitWithTemplateRepository: + """Tests for init command with template repository selection.""" - def test_init_with_go_language(self, tmp_path): - """Test that init with go language creates Go-specific structure.""" - init(tmp_path, git_host="github", language="go") + @patch("rhiza.commands.init._check_template_repository_reachable", return_value=True) + def test_init_with_go_template_repository(self, mock_check, tmp_path): + """Test that init with go template repository creates correct config.""" + init(tmp_path, git_host="github", template_repository="jebel-quant/rhiza-go") - # Verify template.yml was created with go language + # Verify template.yml was created with go repository template_file = tmp_path / ".rhiza" / "template.yml" assert template_file.exists() @@ -22,19 +23,13 @@ def test_init_with_go_language(self, tmp_path): config = yaml.safe_load(f) assert config["repository"] == "jebel-quant/rhiza-go" - assert config["language"] == "go" - - # Verify Go-specific structure was NOT created (user should run go mod init) - assert not (tmp_path / "go.mod").exists() - assert not (tmp_path / "src").exists() - assert not (tmp_path / "pyproject.toml").exists() - - # Only README should be created - assert (tmp_path / "README.md").exists() + # The language parameter defaults to "python" internally; RhizaTemplate.to_yaml() + # omits the language field when it equals the default "python" value. + assert "language" not in config - def test_init_with_python_language_explicit(self, tmp_path): - """Test that init with explicit python language creates Python structure.""" - init(tmp_path, git_host="github", language="python") + def test_init_with_python_template_repository(self, tmp_path): + """Test that init with default python template repository creates Python structure.""" + init(tmp_path, git_host="github") # Verify template.yml was created WITHOUT language field (it's default) template_file = tmp_path / ".rhiza" / "template.yml" @@ -42,7 +37,8 @@ def test_init_with_python_language_explicit(self, tmp_path): config = yaml.safe_load(f) assert config["repository"] == "jebel-quant/rhiza" - # Language field should not be in config (it's the default) + # RhizaTemplate.to_yaml() omits the language field when it equals the + # default "python" value, so no language key is written to the file. assert "language" not in config # Verify Python-specific structure @@ -51,7 +47,7 @@ def test_init_with_python_language_explicit(self, tmp_path): assert (tmp_path / "README.md").exists() def test_init_defaults_to_python(self, tmp_path): - """Test that init defaults to python when no language specified.""" + """Test that init defaults to python when no template repository specified.""" init(tmp_path, git_host="github") # Verify Python structure was created @@ -59,12 +55,11 @@ def test_init_defaults_to_python(self, tmp_path): assert (tmp_path / "src").is_dir() @patch("rhiza.commands.init._check_template_repository_reachable", return_value=True) - def test_init_go_with_custom_template_repository(self, mock_check, tmp_path): - """Test that custom template repository works with Go language.""" + def test_init_with_custom_template_repository(self, mock_check, tmp_path): + """Test that custom template repository is stored correctly.""" init( tmp_path, git_host="github", - language="go", template_repository="custom/go-templates", ) @@ -72,41 +67,19 @@ def test_init_go_with_custom_template_repository(self, mock_check, tmp_path): with open(template_file) as f: config = yaml.safe_load(f) - # Custom repository should override default + # Custom repository should be set assert config["repository"] == "custom/go-templates" - assert config["language"] == "go" - - def test_init_unknown_language(self, tmp_path): - """Test that init handles unknown languages gracefully.""" - init(tmp_path, git_host="github", language="rust") - - # Should create minimal structure - assert (tmp_path / ".rhiza" / "template.yml").exists() - assert (tmp_path / "README.md").exists() - # Should not create language-specific files - assert not (tmp_path / "pyproject.toml").exists() - assert not (tmp_path / "go.mod").exists() - - # Verify template.yml - template_file = tmp_path / ".rhiza" / "template.yml" - with open(template_file) as f: - config = yaml.safe_load(f) - - assert config["language"] == "rust" - # Should use default Python repository since no mapping exists - assert config["repository"] == "jebel-quant/rhiza" - - def test_init_go_language_with_gitlab(self, tmp_path): - """Test Go init with GitLab hosting.""" - init(tmp_path, git_host="gitlab", language="go") + @patch("rhiza.commands.init._check_template_repository_reachable", return_value=True) + def test_init_go_template_repository_with_gitlab(self, mock_check, tmp_path): + """Test go template repository with GitLab hosting.""" + init(tmp_path, git_host="gitlab", template_repository="jebel-quant/rhiza-go") template_file = tmp_path / ".rhiza" / "template.yml" with open(template_file) as f: config = yaml.safe_load(f) assert config["repository"] == "jebel-quant/rhiza-go" - assert config["language"] == "go" # Should include gitlab in templates assert "gitlab" in config["templates"] assert "github" not in config["templates"]