diff --git a/tools/code-owners-parser/Azure.Sdk.Tools.CodeOwnersParser.Tests/CodeownersFileTests.cs b/tools/code-owners-parser/Azure.Sdk.Tools.CodeOwnersParser.Tests/CodeownersFileTests.cs index ab96bca6284..acc3ca06d43 100644 --- a/tools/code-owners-parser/Azure.Sdk.Tools.CodeOwnersParser.Tests/CodeownersFileTests.cs +++ b/tools/code-owners-parser/Azure.Sdk.Tools.CodeOwnersParser.Tests/CodeownersFileTests.cs @@ -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 ), diff --git a/tools/code-owners-parser/CodeOwnersParser/MatchedCodeownersEntry.cs b/tools/code-owners-parser/CodeOwnersParser/MatchedCodeownersEntry.cs index 56db516e998..77ebf40b6e5 100644 --- a/tools/code-owners-parser/CodeOwnersParser/MatchedCodeownersEntry.cs +++ b/tools/code-owners-parser/CodeOwnersParser/MatchedCodeownersEntry.cs @@ -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. {