Skip to content

Commit

Permalink
Create a .gitignore in work_dir and info file directories
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee committed Oct 30, 2023
1 parent 0a2a386 commit cf8817b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tox/session/env_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ def iter( # noqa: A003
yield name

def ensure_only_run_env_is_active(self) -> None:
if not self._state.conf.core["work_dir"].exists():
self._state.conf.core["work_dir"].mkdir()
(self._state.conf.core["work_dir"] / ".gitignore").write_text("*", encoding="utf-8")
envs, active = self._defined_envs, self._env_name_to_active()
invalid = [n for n, a in active.items() if a and isinstance(envs[n].env, PackageToxEnv)]
if invalid:
Expand Down
2 changes: 2 additions & 0 deletions src/tox/tox_env/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def reset(self) -> None:

def _write(self) -> None:
self._path.parent.mkdir(parents=True, exist_ok=True)
if not (self._path.parent / ".gitignore").exists():
(self._path.parent / ".gitignore").write_text("*", encoding="utf-8")
self._path.write_text(json.dumps(self._content, indent=2))


Expand Down

0 comments on commit cf8817b

Please sign in to comment.