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

fix glob_to_regex #4351

Closed
wisechengyi opened this issue Mar 21, 2017 · 7 comments
Closed

fix glob_to_regex #4351

wisechengyi opened this issue Mar 21, 2017 · 7 comments

Comments

@wisechengyi
Copy link
Contributor

wisechengyi commented Mar 21, 2017

  1. checkout branch regex_repo from https://github.com/wisechengyi/pants
  2. ./pants invalidate compile contrib/scrooge/tests/thrift/org/pantsbuild/contrib/scrooge/scrooge_gen:good-thrift, which will fail because
u'.pants.d/gen/scrooge/9f0b049b44d7/contrib.scrooge.tests.thrift.org.pantsbuild.contrib.scrooge.scrooge_gen.good-thrift/current/all/your/base/thriftscala/MyService$FinagleClient.scala'

is NOT matching with

[u'.pants.d/gen/scrooge/9f0b049b44d7/contrib.scrooge.tests.thrift.org.pantsbuild.contrib.scrooge.scrooge_gen.good-thrift/current/all/your/base/thriftscala/MyService$FinagleClient.scala', 
u'.pants.d/gen/scrooge/9f0b049b44d7/contrib.scrooge.tests.thrift.org.pantsbuild.contrib.scrooge.scrooge_gen.good-thrift/current/all/your/base/thriftscala/MyService$FinagleService.scala', 
u'.pants.d/gen/scrooge/9f0b049b44d7/contrib.scrooge.tests.thrift.org.pantsbuild.contrib.scrooge.scrooge_gen.good-thrift/current/all/your/base/thriftscala/MyService.scala']

in https://github.com/wisechengyi/pants/blob/227aa8c279fa754f0790e405f16839d6920fe990/src/python/pants/source/filespec.py#L11

workaround:
https://github.com/wisechengyi/pants/blob/227aa8c279fa754f0790e405f16839d6920fe990/src/python/pants/source/filespec.py#L49-L50

@stuhood
Copy link
Member

stuhood commented Mar 21, 2017

Hmmmm. I'm pretty sure we have another implementation of this somewhere? We use https://pypi.python.org/pypi/pathspec for this in ProjectTree, for example. And the v2 engine uses the rust impl from https://crates.io/crates/glob

@wisechengyi
Copy link
Contributor Author

that's good news. i'll try it out

@stuhood
Copy link
Member

stuhood commented Mar 21, 2017

Oh, I see what's going on (although I have no idea why we're even trying to match files this way... shouldn't the SourcesField matching be enough?). The implementation needs to escape all regex characters.

@JieGhost
Copy link
Contributor

JieGhost commented Mar 21, 2017

This was added in 8565b63.
I think this is what sources payload field uses for matching. The old logic uses fnmatch which has issues.

So the issue here is '$' has to be escaped right?
Are there any possible regex chars other than '.' and '$' in filenames?
Or do we want to play safe and exclude everything that is meaningful in regex?

@wisechengyi
Copy link
Contributor Author

wisechengyi commented Mar 21, 2017 via email

@wisechengyi wisechengyi changed the title fix glob_to_regex (I am too scared to touch it) fix glob_to_regex Mar 21, 2017
@JieGhost
Copy link
Contributor

OK, thanks!

@wisechengyi
Copy link
Contributor Author

closed with #4350

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants