SERVER-92729 Ignore whitespace for commit message validation comparisons (#25191)

GitOrigin-RevId: 4b0e45da036e265971b82500736cdb0db4d8234a
This commit is contained in:
Steve McClure
2024-07-23 12:35:07 -04:00
committed by MongoDB Bot
parent aa11c7f714
commit bfa96e8503
2 changed files with 10 additions and 2 deletions

View File

@@ -70,10 +70,13 @@ def is_valid_commit(commit: Commit) -> bool:
)
return False
# Remove all whitespace from comparisons. GitHub line-wraps commit messages, which adds
# newline characters that otherwise would not match verbatim such banned strings.
stripped_message = "".join(commit.message.split())
for banned_string in BANNED_STRINGS:
if banned_string in commit.message:
if "".join(banned_string.split()) in stripped_message:
LOGGER.error(
"Commit contains banned string",
"Commit contains banned string (ignoring whitespace)",
banned_string=banned_string,
commit_hexsha=commit.hexsha,
commit_message=commit.message,