Skip to content

Commit

Permalink
ongoing
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Jamrozik committed Feb 1, 2023
1 parent 6da835e commit c69c9ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public class CodeownersFileTests
new( "/**" , "[" , false , false ),
new( "/**" , "]" , false , false ),
new( "/**" , "!" , false , false ),
new( "/a*" , "a" , false , true ),
new( "/a*" , "a/x" , false , true ),
new( "/a*" , "a/x/d" , false , true ),
new( "/a*" , "ab" , false , true ),
new( "/a*" , "ab/x" , false , true ),
new( "/a*" , "ab/x/d" , false , true ),
new( "/a/**" , "a" , false , false ),
new( "/*/**" , "a" , false , false ),
new( "/*/**" , "a/" , false , false ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,16 @@ private static string SetPatternSuffix(string pattern)
// even though in such case the path might be a path to a directory.
if (!pattern.EndsWith("/"))
{
// Append "end of string" symbol, denoting the match has to be exact,
// not a substring, as we are dealing with a file.
pattern += "$";
// Manual experiments with how GitHub applies ownership show
// that a path like "/foo*" is effectively equivalent to
// "Match any path with prefix of '/foo'".
// Hence, we are not appending "$" if this is the case.
if (!pattern.EndsWith(SingleStar))
{
// Append "end of string" symbol, denoting the match has to be exact,
// not a substring, as we are dealing with a file.
pattern += "$";
}
}
else // The pattern ends with "/", denoting it is a directory.
{
Expand Down

0 comments on commit c69c9ce

Please sign in to comment.