convex-js icon indicating copy to clipboard operation
convex-js copied to clipboard

Fix `.env.local` additions in `.gitignore`

Open evadecker opened this issue 11 months ago • 5 comments

Discussed in Discord here.

I'm working on an open source repo that requires contributors to initialize Convex on their local machines. I've noticed a few contributors push code that adds .env.local at the bottom of .gitignore, even though it's already listed above. I think this is being added automatically during the initialization process. Is there a way to disable this, or to improve the .gitignore pattern matching so it doesn't get added?

image

This PR updates the changesToGitIgnore() function to more robustly check for .env.local (and related variants), accounting for /r on Windows or extra whitespace which previously led to false positives.

New test cases were added to verify the updated conditions.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

evadecker avatar Dec 22 '24 06:12 evadecker

After reviewing the .gitignore spec: inline comments with # aren't valid. Comments must always start on a new line. Updated the matching + tests to reflect this.

evadecker avatar Dec 22 '24 18:12 evadecker

Thanks for the fix @evadecker! This PR merged in https://github.com/get-convex/convex-js/commit/1af1b7f50e1a0ecfcfe850f51bc804ea41a67f73

thomasballinger avatar Dec 22 '24 19:12 thomasballinger

@thomasballinger it looks like the last commit in my PR was left out of the merged version.

I had to change some logic because inline comments aren't valid in .gitignore, and I was concerned splitting on # could potentially split a directory or file by mistake (very unlikely but possible)

https://github.com/get-convex/convex-js/commit/c853fccb12421a2a104a71cff559b739713f77c6

Also added other test cases

evadecker avatar Dec 22 '24 22:12 evadecker

Oops, thanks. I'll fix that up and fix the script that pulls things into the other repo.

thomasballinger avatar Dec 22 '24 23:12 thomasballinger

@thomasballinger Doing some PR cleanup for myself. It looks like all these changes made it in, can this be closed?

evadecker avatar Apr 29 '25 05:04 evadecker