Skip to content

Commit

Permalink
Improve default .gitignore (#358)
Browse files Browse the repository at this point in the history
- Adds .DS_Store which is created by MacOS
- Adds .ansible which is ansible temp directory
  • Loading branch information
ssbarnea authored Feb 2, 2025
1 parent 3d6251c commit b2d4620
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/ansible_creator/resources/common/gitignore/.gitignore.j2
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,9 @@ cython_debug/
# 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/

# MacOS
.DS_Store

# Ansible
.ansible/
6 changes: 6 additions & 0 deletions tests/fixtures/collection/testorg/testcol/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,9 @@ cython_debug/
# 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/

# MacOS
.DS_Store

# Ansible
.ansible/
6 changes: 6 additions & 0 deletions tests/fixtures/project/playbook_project/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,9 @@ cython_debug/
# 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/

# MacOS
.DS_Store

# Ansible
.ansible/
18 changes: 9 additions & 9 deletions tests/units/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ def mock_unique_name_in_devfile(init: Init) -> str:
result = capsys.readouterr().out

# check stdout
assert re.search("Note: collection project created", result) is not None
assert re.search(r"Note: collection project created", result) is not None

# recursively assert files created
cmp = dircmp(str(tmp_path), str(FIXTURES_DIR / "collection"))
cmp = dircmp(str(tmp_path), str(FIXTURES_DIR / "collection"), ignore=[".DS_Store"])
diff = has_differences(dcmp=cmp, errors=[])
assert diff == [], diff

Expand All @@ -152,12 +152,12 @@ def mock_unique_name_in_devfile(init: Init) -> str:
result = capsys.readouterr().out
assert (
re.search(
"already exists",
r"already exists",
result,
)
is not None
), result
assert re.search("Note: collection project created at", result) is not None, result
assert re.search(r"Note: collection project created at", result) is not None, result

# override existing collection with force=true
cli_args["force"] = True
Expand All @@ -166,7 +166,7 @@ def mock_unique_name_in_devfile(init: Init) -> str:
)
init.run()
result = capsys.readouterr().out
assert re.search("Warning: re-initializing existing directory", result) is not None, result
assert re.search(r"Warning: re-initializing existing directory", result) is not None, result


def test_run_success_ansible_project(
Expand Down Expand Up @@ -209,7 +209,7 @@ def mock_unique_name_in_devfile(init: Init) -> str:
result = capsys.readouterr().out

# check stdout
assert re.search("Note: playbook project created", result) is not None
assert re.search(r"Note: playbook project created", result) is not None

# recursively assert files created
cmp = dircmp(
Expand Down Expand Up @@ -238,12 +238,12 @@ def mock_unique_name_in_devfile(init: Init) -> str:
result = capsys.readouterr().out
assert (
re.search(
"already exists",
r"already exists",
result,
)
is not None
), result
assert re.search("Note: playbook project created at", result) is not None, result
assert re.search(r"Note: playbook project created at", result) is not None, result

# override existing playbook directory with force=true
cli_args["force"] = True
Expand All @@ -252,7 +252,7 @@ def mock_unique_name_in_devfile(init: Init) -> str:
)
init.run()
result = capsys.readouterr().out
assert re.search("Warning: re-initializing existing directory", result) is not None, result
assert re.search(r"Warning: re-initializing existing directory", result) is not None, result


def test_run_success_collections_alt_dir(
Expand Down

0 comments on commit b2d4620

Please sign in to comment.