Merge pull request #2675 from apaz-cli/ap/dotenv_dne

Don't add .env to gitignore when it doesn't exist.
This commit is contained in:
paul-gauthier 2024-12-22 06:00:47 -08:00 committed by GitHub
commit 3dbe91577c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -173,7 +173,8 @@ def check_gitignore(git_root, io, ask=True):
existing_lines = content.splitlines()
for pat in patterns:
if pat not in existing_lines:
patterns_to_add.append(pat)
if '*' in pat or (Path(git_root) / pat).exists():
patterns_to_add.append(pat)
except OSError as e:
io.tool_error(f"Error when trying to read {gitignore_file}: {e}")
return