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

Automatically write .gitignore to cache dir, ignoring everything #8193

Merged
merged 3 commits into from
Jan 21, 2020
Merged
Changes from 2 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
8 changes: 8 additions & 0 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,15 @@ def __init__(self, data_dir: str,
and not has_reporters)
self.fscache = fscache
self.find_module_cache = FindModuleCache(self.search_paths, self.fscache, self.options)
# add ignore-all .gitignore to cache dir if we created it
cache_dir_existed = os.path.isdir(options.cache_dir)
self.metastore = create_metastore(options)
if not cache_dir_existed and os.path.isdir(options.cache_dir):
gitignore = os.path.join(options.cache_dir, ".gitignore")
if not fscache.isfile(gitignore):
with open(gitignore, "w") as f:
print("# Automatically created by mypy", file=f)
print("*", file=f)

# a mapping from source files to their corresponding shadow files
# for efficient lookup
Expand Down