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

Optionally skip creation of .gitignore in virtualenv directory #2004

Merged
merged 4 commits into from
Nov 2, 2020

Conversation

compwiztobe
Copy link
Contributor

@compwiztobe compwiztobe commented Nov 2, 2020

Addresses #2003. Creation of .gitignore with non-overridable * directive in the environment directory interferes with possibly more specific ignore directives in higher directories. When the environment directory is a subdirectory of a repo and we need tracking of a subset of its files, allow to skip creation of this .gitignore with a command line option to virtualenv.

Thanks for contributing, make sure you address all the checklists (for details on how see development documentation)!

  • ran the linter to address style issues (tox -e fix_lint)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

@codecov
Copy link

codecov bot commented Nov 2, 2020

Codecov Report

Merging #2004 into main will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2004      +/-   ##
==========================================
+ Coverage   94.27%   94.29%   +0.02%     
==========================================
  Files          86       86              
  Lines        4277     4280       +3     
==========================================
+ Hits         4032     4036       +4     
+ Misses        245      244       -1     
Flag Coverage Δ
tests 94.29% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/virtualenv/create/creator.py 96.15% <100.00%> (+0.09%) ⬆️
src/virtualenv/seed/embed/base_embed.py 98.11% <0.00%> (+1.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ae716f...6e13306. Read the comment docs.

if ever in the future it becomes possible to implement similar directives
at the subdirectory level for Mercurial, Bazaar, SVN
dest="vcs_ignore",
action="store_false",
help="don't create VCS ignore directive in the destination directory",
default=True,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this break convention and more importantly the CLI option-environment variable interop, by renaming the argument? I wasn't aware of the config-file/env-var pathway to set these, and now it's not clear to me if those will expect a value at no_vcs_ignore/VIRTUALENV_NO_VCS_IGNORE or vcs_ignore/VIRTUALENV_VCS_IGNORE or some combo.

Copy link
Contributor

Choose a reason for hiding this comment

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

So if you put:

[virtualenv]
no_vcs_ignore = false

in your users virtualenv.ini file you enabled this flag always on your machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perfect

@@ -90,6 +92,13 @@ def add_parser_arguments(cls, parser, interpreter, meta, app_data):
help="remove the destination directory if exist before starting (will overwrite files otherwise)",
default=False,
)
parser.add_argument(
"--no-vcs-ignore",
Copy link
Contributor

Choose a reason for hiding this comment

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

VIRTUALENV_NO_VCS_IGNORE and no_vcs_ignore will be the names as documented under https://virtualenv.pypa.io/en/latest/cli_interface.html#environment-variables. The destination variable doesn't matter only the CLI flag.

dest="vcs_ignore",
action="store_false",
help="don't create VCS ignore directive in the destination directory",
default=True,
Copy link
Contributor

Choose a reason for hiding this comment

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

So if you put:

[virtualenv]
no_vcs_ignore = false

in your users virtualenv.ini file you enabled this flag always on your machine.

@@ -90,6 +92,13 @@ def add_parser_arguments(cls, parser, interpreter, meta, app_data):
help="remove the destination directory if exist before starting (will overwrite files otherwise)",
default=False,
)
parser.add_argument(
"--no-vcs-ignore",
dest="vcs_ignore",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like how you negated the flag name, but kept the destination positive. Please keep them in sync. This flag should be --no-vcs-ignore, destination no_vcs_ignore and should store_true with default False.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Wasn't really any reason for old way, other than the double negative on line 172, and "because I can". But bringing into sync also will make the default value in auto-docs less confusing (actually correct).

@pradyunsg
Copy link
Member

pradyunsg commented Nov 2, 2020

I usually find is really awkward to have double-negatives for configuration of tooling (pip is HORRIBLE on this front).

Here's my 2 cents: if we're doing this, let's add --vcs-ignore/--no-vcs-ignore (I don't care about the exact naming) such that the configuration options look like vcs_ignore = false. By having on/off knobs for the boolean, we'd also allow folks to override environment-level "no" with a "yes" CLI flag.

@gaborbernat
Copy link
Contributor

Here's my 2 cents: if we're doing this, let's add --vcs-ignore/--no-vcs-ignore (I don't care about the exact naming) such that the configuration options look like vcs_ignore = false. By having on/off knobs for the boolean, we'd also allow folks to override environment-level "no" with a "yes" CLI flag.

Supporting --flag/--no-flag would be a generic feature we don't do at the moment and I'm personally not totally sold on it (or interested in implementing it). Either way, would this be done I would not single out a new flag, but implement it for all boolean flags, which is clearly out of the scope of this PR.

Copy link
Contributor

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

@gaborbernat gaborbernat merged commit 9708b54 into pypa:main Nov 2, 2020
@compwiztobe compwiztobe deleted the no-gitignore branch November 2, 2020 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants