Thanks Yujie: looks good.
This method probably deserves a better description... in particular, it looks like it assumes that the value at idx 0 ==
Alternatively, maybe move validating the assumption into the method? Could also move in the
ValueErrorfor malformed values.
sortedin both of these cases would let you drop the
lencheck, and would likely be easier to debug.
RGlobs.to_filespec should generate filespecs that match git spec
Review Request #4078 — Created July 13, 2016 and submitted
|kwlzn, nhoward_tw, stuhood|
In v1 engine's rglobs implementation, '**' matches 1 or more dirs.
In v2 engine, we want to make rglobs follow git spec, which means '**' in BUILD file should match 0 or more dirs.
v2 engine used to treat '**' as matching 1 or more dirs. Thus for a pattern like 'a/**/*.py', RGlobs.to_filespec will generate 2 filespecs: 'a/**/*.py' and 'a/*.py', to make '**' from BUILD files match 0 or more dirs. However, after https://rbcommons.com/s/twitter/r/4034/, v2 engine started to match '**' with 0 or more dirs directly. The additional logic of handling '**' in RGlobs.to_filespec can be removed then.
In this patch,
1. RGlobs.to_filespec is simplified.
2. Add a logic in PathGlob.create to replace consecutive '**' with a single '**'.
3. Fix test failures caused by 1.
Revision 2 (+49 -94)