From eac94ef5dcc80ce22225673dc0c4f6da961d0b4b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:46:11 +0000 Subject: [PATCH 1/2] Initial plan From 5401b5b66a70fa8e4de091e677d15ff2c1eaea83 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 16 Mar 2026 13:53:48 +0000 Subject: [PATCH 2/2] Add uv.lock to .gitignore for library projects - Rename .gitignore to .gitignore.jinja to enable Jinja templating - Add conditional block: uv.lock is ignored for 'library' projects, not for 'command', 'notebook', or 'custom' - Add test to verify conditional behavior across project types Co-authored-by: hombit <1784493+hombit@users.noreply.github.com> --- .../{.gitignore => .gitignore.jinja} | 4 +++ tests/test_package_creation.py | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+) rename python-project-template/{.gitignore => .gitignore.jinja} (97%) diff --git a/python-project-template/.gitignore b/python-project-template/.gitignore.jinja similarity index 97% rename from python-project-template/.gitignore rename to python-project-template/.gitignore.jinja index 50990fec..5ab90d07 100644 --- a/python-project-template/.gitignore +++ b/python-project-template/.gitignore.jinja @@ -148,3 +148,7 @@ _html/ # Project initialization script .initialize_new_project.sh +{% if custom_install == 'library' %} +# uv +uv.lock +{% endif %} diff --git a/tests/test_package_creation.py b/tests/test_package_creation.py index 28529fed..315c204e 100644 --- a/tests/test_package_creation.py +++ b/tests/test_package_creation.py @@ -231,3 +231,31 @@ def test_github_workflows_schema(copie, default_answers): "include_docs": True, } create_project_with_basic_checks(copie, extra_answers) + + +@pytest.mark.parametrize( + "custom_install,uv_lock_ignored", + [ + ("library", True), + ("command", False), + ("notebook", False), + ("custom", False), + ], +) +def test_uv_lock_in_gitignore(copie, default_answers, custom_install, uv_lock_ignored): + """Confirm that uv.lock is added to .gitignore only for library projects.""" + extra_answers = default_answers | {"custom_install": custom_install} + result = copie.copy(extra_answers=extra_answers) + + assert result.exit_code == 0 and result.exception is None + + gitignore_path = result.project_dir / ".gitignore" + assert gitignore_path.is_file() + + with open(gitignore_path, encoding="utf-8") as f: + gitignore_content = f.read() + + if uv_lock_ignored: + assert "uv.lock" in gitignore_content + else: + assert "uv.lock" not in gitignore_content