diff --git a/copier.yml b/copier.yml index 6ea49a33..3302cf9f 100644 --- a/copier.yml +++ b/copier.yml @@ -45,6 +45,12 @@ _migrations: - --search-root={{ _copier_conf.src_path }} - --collection=migrations - from-doodba-scaffolding-to-copier + - version: v1.5.2 + after: + - - invoke + - --search-root={{ _copier_conf.src_path }} + - --collection=migrations + - remove-odoo-auto-folder # Questions for the user project_author: diff --git a/migrations.py b/migrations.py index 19ece1fc..4cef182f 100644 --- a/migrations.py +++ b/migrations.py @@ -29,3 +29,15 @@ def from_doodba_scaffolding_to_copier(c): "[*.yml]", "[*.{code-snippets,code-workspace,json,md,yaml,yml}{,.jinja}]", 1 ) editorconfig_file.write_text(editorconfig_contents) + + +@task +def remove_odoo_auto_folder(c): + """This folder makes no more sense for us. + + The `invoke develop` task now handles its creation, which is done with + host user UID and GID to avoid problems. + + There's no need to have it in our code tree anymore. + """ + shutil.rmtree(Path("odoo", "auto"), ignore_errors=True) diff --git a/tasks.py b/tasks.py index 25cb1601..97259fed 100644 --- a/tasks.py +++ b/tasks.py @@ -113,6 +113,7 @@ def update_test_samples(c): dst = default_settings_path / f"v{v}" c.run(f"poetry run copier -fr test -d odoo_version={v} copy . {dst}") shutil.rmtree(dst / ".git") + shutil.rmtree(dst / "odoo" / "auto") finally: c.run("git tag --delete test") samples = Path("tests", "samples") diff --git a/tasks_downstream.py b/tasks_downstream.py index 3b238075..ba28fd3f 100644 --- a/tasks_downstream.py +++ b/tasks_downstream.py @@ -80,6 +80,7 @@ def develop(c): c.run("python3 -m pip install --user pipx") c.run(f"pipx install {dep}") # Prepare environment + Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True) with c.cd(str(PROJECT_ROOT)): c.run("git init") c.run("ln -sf devel.yaml docker-compose.yml") diff --git a/tests/default_settings/v10.0/tasks.py b/tests/default_settings/v10.0/tasks.py index c41095e8..0a3ed334 100644 --- a/tests/default_settings/v10.0/tasks.py +++ b/tests/default_settings/v10.0/tasks.py @@ -81,6 +81,7 @@ def develop(c): c.run("python3 -m pip install --user pipx") c.run(f"pipx install {dep}") # Prepare environment + Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True) with c.cd(str(PROJECT_ROOT)): c.run("git init") c.run("ln -sf devel.yaml docker-compose.yml") diff --git a/tests/default_settings/v11.0/tasks.py b/tests/default_settings/v11.0/tasks.py index 3b238075..ba28fd3f 100644 --- a/tests/default_settings/v11.0/tasks.py +++ b/tests/default_settings/v11.0/tasks.py @@ -80,6 +80,7 @@ def develop(c): c.run("python3 -m pip install --user pipx") c.run(f"pipx install {dep}") # Prepare environment + Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True) with c.cd(str(PROJECT_ROOT)): c.run("git init") c.run("ln -sf devel.yaml docker-compose.yml") diff --git a/tests/default_settings/v12.0/tasks.py b/tests/default_settings/v12.0/tasks.py index 3b238075..ba28fd3f 100644 --- a/tests/default_settings/v12.0/tasks.py +++ b/tests/default_settings/v12.0/tasks.py @@ -80,6 +80,7 @@ def develop(c): c.run("python3 -m pip install --user pipx") c.run(f"pipx install {dep}") # Prepare environment + Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True) with c.cd(str(PROJECT_ROOT)): c.run("git init") c.run("ln -sf devel.yaml docker-compose.yml") diff --git a/tests/default_settings/v13.0/tasks.py b/tests/default_settings/v13.0/tasks.py index 3b238075..ba28fd3f 100644 --- a/tests/default_settings/v13.0/tasks.py +++ b/tests/default_settings/v13.0/tasks.py @@ -80,6 +80,7 @@ def develop(c): c.run("python3 -m pip install --user pipx") c.run(f"pipx install {dep}") # Prepare environment + Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True) with c.cd(str(PROJECT_ROOT)): c.run("git init") c.run("ln -sf devel.yaml docker-compose.yml") diff --git a/tests/default_settings/v7.0/tasks.py b/tests/default_settings/v7.0/tasks.py index c41095e8..0a3ed334 100644 --- a/tests/default_settings/v7.0/tasks.py +++ b/tests/default_settings/v7.0/tasks.py @@ -81,6 +81,7 @@ def develop(c): c.run("python3 -m pip install --user pipx") c.run(f"pipx install {dep}") # Prepare environment + Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True) with c.cd(str(PROJECT_ROOT)): c.run("git init") c.run("ln -sf devel.yaml docker-compose.yml") diff --git a/tests/default_settings/v8.0/tasks.py b/tests/default_settings/v8.0/tasks.py index c41095e8..0a3ed334 100644 --- a/tests/default_settings/v8.0/tasks.py +++ b/tests/default_settings/v8.0/tasks.py @@ -81,6 +81,7 @@ def develop(c): c.run("python3 -m pip install --user pipx") c.run(f"pipx install {dep}") # Prepare environment + Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True) with c.cd(str(PROJECT_ROOT)): c.run("git init") c.run("ln -sf devel.yaml docker-compose.yml") diff --git a/tests/default_settings/v9.0/tasks.py b/tests/default_settings/v9.0/tasks.py index c41095e8..0a3ed334 100644 --- a/tests/default_settings/v9.0/tasks.py +++ b/tests/default_settings/v9.0/tasks.py @@ -81,6 +81,7 @@ def develop(c): c.run("python3 -m pip install --user pipx") c.run(f"pipx install {dep}") # Prepare environment + Path(PROJECT_ROOT, "odoo", "auto").mkdir(exist_ok=True) with c.cd(str(PROJECT_ROOT)): c.run("git init") c.run("ln -sf devel.yaml docker-compose.yml") diff --git a/tests/test_default_settings.py b/tests/test_default_settings.py index 688d0ae3..711e140a 100644 --- a/tests/test_default_settings.py +++ b/tests/test_default_settings.py @@ -28,6 +28,7 @@ def test_default_settings( with local.cwd(dst): # TODO When copier runs pre-commit before extracting diff, make sure # here that it works as expected + Path(dst, "odoo", "auto").rmdir() git("add", ".") git("commit", "-am", "Hello World", retcode=1) # pre-commit fails git("commit", "-am", "Hello World") diff --git a/tests/test_transition_to_copier.py b/tests/test_migrations.py similarity index 77% rename from tests/test_transition_to_copier.py rename to tests/test_migrations.py index e1164909..ee620818 100644 --- a/tests/test_transition_to_copier.py +++ b/tests/test_migrations.py @@ -83,3 +83,33 @@ def test_transtion_to_copier( "migrations", "from-doodba-scaffolding-to-copier", ) + + +def test_v1_5_2_migration( + tmp_path: Path, cloned_template: Path, supported_odoo_version: float +): + """Test migration to v1.5.2.""" + auto = tmp_path / "odoo" / "auto" + empty = auto / ".empty" # This file existed in doodba-scaffolding + # This part makes sense v1.5.2 is not yet released + with local.cwd(cloned_template): + if "v1.5.2" not in git("tag").split(): + git("tag", "-d", "test") + git("tag", "v1.5.2") + with local.cwd(tmp_path): + # Copy v1.5.1 + copy(src_path=str(cloned_template), vcs_ref="v1.5.1", force=True) + auto.mkdir() + empty.touch() + assert empty.exists() + git("add", ".") + git("add", "-f", empty) + git("commit", "-am", "reformat", retcode=1) + git("commit", "-am", "copied from template in v1.5.1") + # Update to v1.5.2 + copy(vcs_ref="v1.5.2", force=True) + assert not empty.exists() + assert not auto.exists() + invoke("develop") + assert auto.exists() + assert not empty.exists()