Skip to content

Commit

Permalink
{CI} Keep the logic consistent with generate_history_notes.py, always…
Browse files Browse the repository at this point in the history
… check history notes (Azure#22539)

* Update check_pull_request.py

* Update check_pull_request.py
  • Loading branch information
wangzelin007 authored May 24, 2022
1 parent f2b5dbc commit a75dcca
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions scripts/ci/check_pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ def main():


def check_pull_request(title, body):
if title.startswith('['):
error_flag = regex_line(title)
if title.startswith('[') or title.startswith('{'):
error_flag = False
# only check title which start with `[`
if title.startswith('['):
error_flag = check_line(title)
is_edit_history_note = False
history_note_error_flag = False
for line in body:
Expand All @@ -89,18 +92,18 @@ def check_pull_request(title, body):
ref = re.findall(r'[\[](.*?)[\]]', line)
if ref and ref[0] not in ['Component Name 1', 'Component Name 2']:
is_edit_history_note = True
history_note_error_flag = regex_line(line) or history_note_error_flag
# If edit history notes, ignore title check result
history_note_error_flag = check_line(line) or history_note_error_flag
# If the `History Notes` is edited:
# Use the history notes check result (history_note_error_flag), ignore the title check result (error_flag).
error_flag = error_flag if not is_edit_history_note else history_note_error_flag
elif title.startswith('{'):
error_flag = False
else:
logger.error('Pull Request title should start with [ or { , Please follow https://aka.ms/submitAzPR')
error_flag = True
return error_flag


def regex_line(line):
def check_line(line):
# check every line
error_flag = False
# Check Fix #number in title, just give a warning here, because it is not necessarily.
if 'Fix' in line:
Expand Down

0 comments on commit a75dcca

Please sign in to comment.