-
Notifications
You must be signed in to change notification settings - Fork 10
feat(templates): scaffold a .gitignore that excludes .env and .venv #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,6 +99,7 @@ def create_project_structure( | |
| # Create root files | ||
| root_templates = { | ||
| ".dockerignore.j2": ".dockerignore", | ||
| ".gitignore.j2": ".gitignore", | ||
| ".env.example.j2": ".env.example", | ||
| "manifest.yaml.j2": "manifest.yaml", | ||
| "README.md.j2": "README.md", | ||
|
|
@@ -118,7 +119,17 @@ def create_project_structure( | |
|
|
||
| for template, output in root_templates.items(): | ||
| output_path = project_dir / output | ||
| output_path.write_text(render_template(template, context, template_type)) | ||
| rendered = render_template(template, context, template_type) | ||
| if output == ".gitignore" and output_path.exists(): | ||
| # Re-running init on an existing project: keep the user's rules and | ||
| # append only the scaffold entries that are missing. | ||
| existing = output_path.read_text() | ||
| 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: | ||
|
Comment on lines
+127
to
+129
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When an existing Prompt To Fix With AIThis 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. |
||
| output_path.write_text(existing.rstrip("\n") + "\n\n# Added by agentex init\n" + "\n".join(missing) + "\n") | ||
| continue | ||
| output_path.write_text(rendered) | ||
|
|
||
| console.print(f"\n[green]✓[/green] Created project structure at: {project_dir}") | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Secrets and local config | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
|
|
||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| .venv/ | ||
| venv/ | ||
| *.egg-info/ | ||
| build/ | ||
| dist/ | ||
|
|
||
| # Tooling | ||
| .ipynb_checkpoints/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .mypy_cache/ | ||
| .DS_Store |
Uh oh!
There was an error while loading. Please reload this page.