fix: handling !pattern in gitignore to avoid excluding everything from watching in sandbox #671
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes:
A
!
pattern have different meanings for .gitignore and glob pattern (used in sandbox excludes).The
!
pattern in gitignore means explicitly to add back (i.e. include) the file/folder immediately followed by!
if other more generic patterns are excluding it.However in glob patterns,
!
pattern means include everything but the file/folder immediately followed by!
As an example for a .gitignore file
If this file is fed to the sandbox's watcher exclude, it will essentially means exclude everything but
file-i-want-to-check-in.ts
overriding thesrc
,amplify
directories and everything else.sandbox's watcher include doesn't allow glob patterns, so we can't add these patterns in the include section.
As a short term solution, in this PR, we detect presence of
!
and ignore them such that it gets neither "specifically included" or exclude everything from watching and we tell customers that we are explicitly not watching a certain set of files.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.