Skip to content

Commit a0589e0

Browse files
Copilothombit
andauthored
Add uv.lock to .gitignore for library projects (#577)
* Initial plan * 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> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: hombit <1784493+hombit@users.noreply.github.com>
1 parent 81da275 commit a0589e0

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,7 @@ _html/
148148

149149
# Project initialization script
150150
.initialize_new_project.sh
151+
{% if custom_install == 'library' %}
152+
# uv
153+
uv.lock
154+
{% endif %}

tests/test_package_creation.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,31 @@ def test_github_workflows_schema(copie, default_answers):
231231
"include_docs": True,
232232
}
233233
create_project_with_basic_checks(copie, extra_answers)
234+
235+
236+
@pytest.mark.parametrize(
237+
"custom_install,uv_lock_ignored",
238+
[
239+
("library", True),
240+
("command", False),
241+
("notebook", False),
242+
("custom", False),
243+
],
244+
)
245+
def test_uv_lock_in_gitignore(copie, default_answers, custom_install, uv_lock_ignored):
246+
"""Confirm that uv.lock is added to .gitignore only for library projects."""
247+
extra_answers = default_answers | {"custom_install": custom_install}
248+
result = copie.copy(extra_answers=extra_answers)
249+
250+
assert result.exit_code == 0 and result.exception is None
251+
252+
gitignore_path = result.project_dir / ".gitignore"
253+
assert gitignore_path.is_file()
254+
255+
with open(gitignore_path, encoding="utf-8") as f:
256+
gitignore_content = f.read()
257+
258+
if uv_lock_ignored:
259+
assert "uv.lock" in gitignore_content
260+
else:
261+
assert "uv.lock" not in gitignore_content

0 commit comments

Comments
 (0)