Skip to content

Commit

Permalink
[github-nfbot] More improvements on badly formatted check lists
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes committed Jan 3, 2025
1 parent 07d8909 commit 8187f7f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions github-nfbot/GitHub-nfbot/GitHub_nfbot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1433,11 +1433,17 @@ private static async Task FixCheckListAsync(dynamic payload, ILogger log)
var prBodyHash = prBody.GetHashCode();

// fix any typos in check lists
// Define a regex pattern to match any character inside the brackets, including optional spaces
string badCheckBoxesPattern = @"\[\s*[^\s\]]\s*\]";
// Define a regex pattern to match any character inside the brackets
string badCheckBoxesPattern = @"-?\s*\[\s*([^\s\]]|)\s*\]";

// Replace all matches with "[x]"
string prBodyFixed = Regex.Replace(prBody, badCheckBoxesPattern, "[x]");
// Replace all matches with "-[x]"
string prBodyFixed = Regex.Replace(prBody, badCheckBoxesPattern, "- [x]");

// now catch all check boxes with more than one space between the brackets
string badCheckBoxesPattern2 = @"-?\s*\[\s{2,}([^\s\]]|)\s{2,}\]";

// Replace all matches with "[ ]"
prBodyFixed = Regex.Replace(prBodyFixed, badCheckBoxesPattern2, "- [ ]");

if (prBodyHash != prBodyFixed.GetHashCode())
{
Expand Down

0 comments on commit 8187f7f

Please sign in to comment.