Skip to content

[Finder] Adjust regex to correctly match comments in gitignore contents #33340

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

Merged
merged 1 commit into from
Sep 16, 2019

Conversation

Jeroeny
Copy link
Contributor

@Jeroeny Jeroeny commented Aug 26, 2019

Q A
Branch? 4.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #32985
License MIT

Description from issue:

When using ignoreVCSIgnored as argument with the Symfony Finder, it will construct a regex equivalent of the gitignore pattern. However it seems that when a comment line (prefixed with #) is present in the .gitignore, the regex used to remove comment lines matches every line and thus returns $gitignoreFileContent as empty.

@Jeroeny
Copy link
Contributor Author

Jeroeny commented Sep 16, 2019

Ready to merge or is more review needed?

[
'
/app/cache/
\#EscapedComment
Copy link
Member

Choose a reason for hiding this comment

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

What about using a real file name to check that it will be in the list (#file.txt like in a test above)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That'd indeed be more useful, I'll change it.

@fabpot fabpot force-pushed the finder-gitignore-regex-43 branch from 33b2695 to e56fc7c Compare September 16, 2019 11:29
@fabpot
Copy link
Member

fabpot commented Sep 16, 2019

Thank you @Jeroeny.

fabpot added a commit that referenced this pull request Sep 16, 2019
…nore contents (Jeroeny)

This PR was squashed before being merged into the 4.3 branch (closes #33340).

Discussion
----------

[Finder] Adjust regex to correctly match comments in gitignore contents

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32985
| License       | MIT

Description from issue:

When using `ignoreVCSIgnored`  as argument with the Symfony Finder, it will construct a regex equivalent of the gitignore pattern. However it seems that when a comment line (prefixed with `#`) is present in the `.gitignore`, the regex used to remove comment lines matches every line and thus returns `$gitignoreFileContent` as empty.

Commits
-------

e56fc7c [Finder] Adjust regex to correctly match comments in gitignore contents
@fabpot fabpot merged commit e56fc7c into symfony:4.3 Sep 16, 2019
@fabpot fabpot mentioned this pull request Oct 7, 2019
@Jeroeny Jeroeny deleted the finder-gitignore-regex-43 branch December 2, 2019 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants