feat(templates): scaffold a .gitignore that excludes .env and .venv - #513
michaelxu2288 wants to merge 2 commits into
Conversation
| existing_lines = {line.strip() for line in existing.splitlines()} | ||
| missing = [line for line in rendered.splitlines() if line.strip() and not line.startswith("#") and line.strip() not in existing_lines] | ||
| if missing: |
There was a problem hiding this comment.
When an existing .gitignore already contains !.env.example but does not contain .env.*, this order-insensitive check skips the existing negation and appends .env.* after it. Git uses the last matching rule, so rerunning agentex init then ignores .env.example even though the scaffold promises that the example file remains committable. Preserve the template rules as an ordered block or otherwise account for their effective order when merging.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agentex/lib/cli/commands/init.py
Line: 127-129
Comment:
**Gitignore Rule Order Breaks**
When an existing `.gitignore` already contains `!.env.example` but does not contain `.env.*`, this order-insensitive check skips the existing negation and appends `.env.*` after it. Git uses the last matching rule, so rerunning `agentex init` then ignores `.env.example` even though the scaffold promises that the example file remains committable. Preserve the template rules as an ordered block or otherwise account for their effective order when merging.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.bc51c52 to
761833e
Compare
agentex init writes an .env.example and tells users to create .env with their API key, and the Dockerfile path is protected by .dockerignore, but no template ships a .gitignore. A user who git-inits the scaffolded folder commits .env (and .venv) on the first add. Add a .gitignore to every template (secrets, Python artifacts, tool caches; .env.example stays committable) and a test asserting each scaffold renders it. Claude-Session: https://claude.ai/code/session_01HCVKnA7LeJZ44nxZz1uzF3
… of overwriting it Re-running agentex init on an existing project replaced the user's .gitignore. Keep the existing file and append only the scaffold entries that are missing, with a test for the merge. Claude-Session: https://claude.ai/code/session_01HCVKnA7LeJZ44nxZz1uzF3
837f57f to
1df5a34
Compare
Comments Outside DiffThese findings could not be posted inline.
|
What
agentex initwrites.env.exampleand tells users to create.envwith an API key..dockerignoreprotects the image build, but no template ships a.gitignore, sogit init && git add .in a scaffolded folder commits.env(and.venv). Adds a.gitignore.j2to all 19 templates (secrets, Python artifacts, tool caches;.env.examplestays committable), registers it inroot_templatesincommands/init.py, and adds a parametrized test asserting every scaffold renders it with.envand.venv/excluded.Test
tests/lib/cli/test_init_templates.py: 45 passed (26 existing + 19 new). ruff clean.The PR is not ready to merge while rerunning
agentex initcan make.env.exampleignored.Fix with agent prompt
Summary
The PR adds
.gitignorefiles to all 19agentex inittemplates and makes task creation wait for its workflow to start. It also updates release and CI automation for a main-only production flow, adds security scan workflows, and points production clients at the hosted Agentex service..env.exampleshareable while excluding local secrets, virtual environments, and Python tool files.main.Reviews (3) · Last reviewed commit: "fix(init): merge scaffold entries into a..."