Match only top level files
Nicolás Alvarez
nicolas.alvarez at gmail.com
Wed Apr 12 19:52:55 UTC 2017
2017-04-12 5:30 GMT-03:00 John Lawlor <jk.lawlor at gmail.com>:
> Hi,
>
> I have this regex:
>
> match /Labs/ChattyApps/(.*.project|build.xml?)$
> repository /Labs/ChattyApps
> branch master
> prefix \1
> end match
>
> This descends into each folder and matches .project within each, and builds
> the folder structure above the .project file. So the ChattyApps directory
> has the two files I wanted: build.xml and .project, but it also has 5
> folders I don't want, because these folders contain .project files.
>
> Is there a way to just match the two files in the root directory: .project
> and build.xml and don't descend into any other folders to find other
> .project/build.xml matches?
If you don't want to match subdirectories, don't use ".*".
If the file you want is literally called ".project", just use
"(.project|build.xml)". If your file has a .project extension but it
could be anything, like myapp.project, use "[^/]+.project" to match
any characters *except* the slash; that way app.project matches, but
foo/app.project doesn't.
To make the regex even more precise, you should use "\." instead of
".", since "." means any character. Currently it would match buildyxml
or aproject. The question mark also doesn't make much sense, since it
makes the final "l" optional and would match build.xml or build.xm.
But, of course, this doesn't really matter if you don't have such
filenames in your repository.
Hope that helps!
--
Nicolás
More information about the Kde-scm-interest
mailing list