Skip to content
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

Add gitignore support #150

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ESCDELAY
extlinks
facelessuser
fedoraproject
fileh
flatmap
fontawesome
fqcn
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_creator/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
if sys.version_info >= (3, 11):
from importlib.resources.abc import Traversable
else:
from importlib.abc import Traversable
from importlib.abc import Traversable # pylint: disable=W4904
161 changes: 161 additions & 0 deletions src/ansible_creator/resources/common/gitignore/.gitignore.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{{ additions }}# https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
19 changes: 19 additions & 0 deletions src/ansible_creator/resources/common/gitignore/__meta__.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
new_collection:
additions:
template: False
value: ""

ansible_project:
additions:
template: True
value: |
.logs/*
*.retry
*.vault
collections/*
!collections/ansible_collections
!collections/requirements.yml
collections/ansible_collections/*
!collections/ansible_collections/{{ scm_org}}
NilashishC marked this conversation as resolved.
Show resolved Hide resolved
collections/ansible_collections/{{ scm_org }}/*
!collections/ansible_collections/{{ scm_org }}/{{ scm_project }}
30 changes: 21 additions & 9 deletions src/ansible_creator/subcommands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from ansible_creator.exceptions import CreatorError
from ansible_creator.templar import Templar
from ansible_creator.utils import copy_container
from ansible_creator.utils import Copier


if TYPE_CHECKING:
Expand Down Expand Up @@ -94,18 +94,24 @@ def run(self: Init) -> None:
if self._project == "collection":
# copy new_collection container to destination, templating files when found
self.output.debug(msg="started copying collection skeleton to destination")
copy_container(
source="new_collection",
copier = Copier(
resources=[
"new_collection",
"common.devcontainer",
"common.devfile",
"common.gitignore",
],
resource_id="new_collection",
dest=self._init_path,
output=self.output,
templar=self._templar,
template_data={
"namespace": self._namespace,
"collection_name": self._collection_name,
"creator_version": self._creator_version,
},
output=self.output,
common_resources=["devcontainer", "devfile"],
)
copier.copy_containers()

self.output.note(
f"collection {self._namespace}.{self._collection_name} "
Expand All @@ -116,18 +122,24 @@ def run(self: Init) -> None:
self.output.debug(
msg="started copying ansible-project skeleton to destination",
)
copy_container(
source="ansible_project",
copier = Copier(
resources=[
"ansible_project",
"common.devcontainer",
"common.devfile",
"common.gitignore",
],
resource_id="ansible_project",
dest=self._init_path,
output=self.output,
templar=self._templar,
template_data={
"scm_org": self._scm_org,
"scm_project": self._scm_project,
"creator_version": self._creator_version,
},
output=self.output,
common_resources=["devcontainer", "devfile"],
)
copier.copy_containers()

self.output.note(
f"ansible project created at {self._init_path}",
Expand Down
Loading
Loading