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

Ensure that the virtualenv dir is ignored from Git #1817

Closed
wants to merge 1 commit into from
Closed
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 docs/changelog/1806.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure that the virtualenv dir created is ignored by Git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not follow the example structure, e.g. missing user

9 changes: 9 additions & 0 deletions src/virtualenv/create/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ def run(self):
safe_delete(self.dest)
self.create()
self.set_pyenv_cfg()
self._ensure_gitignore()

def _ensure_gitignore(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@gaborbernat gaborbernat May 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yeah please add an option to select and extend this similar to how we do with activators.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not make it git specific, let's cover all VCS covered here https://www.python.org/dev/peps/pep-0610/#registered-vcs

a better name is: generate_vcs_ignore, no need to make it private

"""
Ignore the virtualenv directory from git.
"""
self.dest.joinpath(".gitignore").write_text(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the / instead of join path

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the utf-8 encoding is not needed can leave it empty to use platform default;

the comment is not needed, please remove

"# placed by virtualenv automatically, do not change\n*", encoding="UTF-8"
)

def set_pyenv_cfg(self):
self.pyenv_cfg.content = OrderedDict()
Expand Down