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

Case Insensitive Moniker Parsing #7700

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ public void TestMonikerParsingForMonikerLines(string moniker, string line)
Assert.That(parsedMoniker, Is.EqualTo(moniker), $"ParseMonikerFromLine for '{line}' should have returned '{moniker}' but returned '{parsedMoniker}'");
}

[Category("Utils")]
[Category("Moniker")]
// Case Insensitive Tests
[TestCase(MonikerConstants.AzureSdkOwners, $"# AzureSDKOwners: @fakeOwner1 @fakeOwner2")]
[TestCase(MonikerConstants.AzureSdkOwners, $"# azureSdkowners: @fakeOwner1 @fakeOwner2")]
[TestCase(MonikerConstants.PRLabel, $"# prlabel: %Fake Label")]
[TestCase(MonikerConstants.PRLabel, $"# PrLabel: %Fake Label")]
[TestCase(MonikerConstants.ServiceLabel, $"# serviceLabel: %Fake Label")]
[TestCase(MonikerConstants.ServiceLabel, $"# SERVICELABEL: %Fake Label")]
[TestCase(MonikerConstants.ServiceOwners, $"# seRvICEowners:")]
[TestCase(MonikerConstants.ServiceOwners, $"# serviceOwners:")]
public void TestMonikerParsingForMonikerLinesCaseInsensitive(string moniker, string line)
{
// The MonikerUtils has 2 methods to test for Moniker parsing
// 1. ParseMonikerFromLine - returns the moniker if one is found on the line
// 2. IsMonikerLine - returns true if the line is a moniker line
bool isMonikerLine = MonikerUtils.IsMonikerLine(line);
Assert.IsTrue(isMonikerLine, $"IsMonikerLine for '{line}' contains '{moniker}' and should have returned true.");
string parsedMoniker = MonikerUtils.ParseMonikerFromLine(line);
Assert.That(parsedMoniker, Is.EqualTo(moniker), $"ParseMonikerFromLine for '{line}' should have returned '{moniker}' but returned '{parsedMoniker}'");
}

[Category("Utils")]
[Category("Moniker")]
[TestCase("# just a comment line")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static string ParseMonikerFromLine(string line)
{
// Line starts with "<Moniker>:", unfortunately /<NotInRepo>/ has no colon and needs
// to be checked separately
if (strippedLine.StartsWith($"{tempMoniker}{SeparatorConstants.Colon}"))
if (strippedLine.StartsWith($"{tempMoniker}{SeparatorConstants.Colon}", StringComparison.OrdinalIgnoreCase))
{
return tempMoniker;
}
Expand Down Expand Up @@ -69,7 +69,7 @@ public static bool IsMonikerLine(string line)
{
// Line starts with "<Moniker>:", unfortunately /<NotInRepo>/ has no colon and needs
// to be checked separately
if (strippedLine.StartsWith($"{tempMoniker}{SeparatorConstants.Colon}"))
if (strippedLine.StartsWith($"{tempMoniker}{SeparatorConstants.Colon}", StringComparison.OrdinalIgnoreCase))
{
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions tools/codeowners-utils/METADATA.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ This list of examples is exhaustive. If an example isn't in here then it won't w
```text

# AzureSdkOwners: @fakeUser3 @fakeUser4
# ServiceLabel: %fakeLabel12
/sdk/SomePath/ @fakeUser1 @fakeUser2 @Azure/fakeTeam1
OR
# AzureSdkOwners:
# ServiceLabel: %fakeLabel12
/sdk/SomePath/ @fakeUser1 @fakeUser2 @Azure/fakeTeam1
OR
# AzureSdkOwners: @fakeUser3 @fakeUser4
Expand Down