From 13cc83d8ec23c1e6d6878587af3db87157b9b85b Mon Sep 17 00:00:00 2001 From: ZelinWang Date: Fri, 4 Mar 2022 10:42:08 +0800 Subject: [PATCH] Update check_pull_request.py (#21493) --- scripts/ci/check_pull_request.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/ci/check_pull_request.py b/scripts/ci/check_pull_request.py index 2c649aab704..94e34e890c3 100644 --- a/scripts/ci/check_pull_request.py +++ b/scripts/ci/check_pull_request.py @@ -122,8 +122,13 @@ def regex_line(line): logger.info('%s%s: missing ` around %s', line, yellow, command) logger.error(' ' * idx + '↑' + ' ' * (index - idx - 2) + '↑') error_flag = True - # First word after the colon must be capitalized if i == ':': + # check extra space character before colon + if idx - 1 >= 0 and line[idx - 1] == ' ': + logger.info('%s%s: please delete extra space character before :', line, yellow) + logger.error(' ' * (idx - 1) + '↑') + error_flag = True + # First word after the colon must be capitalized index = 0 if line[idx + 1] == ' ' and line[idx + 2].islower() and line[idx + 2: idx + 5] != 'az ': index = idx + 2 @@ -163,6 +168,17 @@ def regex_line(line): 'follow https://aka.ms/submitAzPR\n', red, word, yellow, green, k, yellow) error_flag = True break + # check extra consecutive spaces + if i == ' ' and (idx + 1) < len(line) and line[idx + 1] == ' ': + logger.info('%s%s: please delete the extra space character', line, yellow) + logger.error(' ' * (idx + 1) + '↑') + error_flag = True + + # last character check + if line[-1] in ['.', ',', ' ']: + logger.info('%s%s: please delete the last character', line, yellow) + logger.error(' ' * idx + '↑') + error_flag = True return error_flag