From bc09f1a334e9ec7bb02eac95424f7fd6b64a16cb Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 4 Nov 2020 11:03:56 -0800 Subject: [PATCH] Tools: Allow cherry pick lines in validate-commit.py. Cherry picking tends to add an extra blank line to the commit message. Update the body check in validate-commit.py to allow for this. Revert "tools: Skip over commit body checks." This reverts commit 24450d9c51ca48ef09eec2cb68426fb274eee998. (cherry picked from commit dd6b6f48dc4b485740edbaa286b248556c9c03d6) --- tools/validate-commit.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/validate-commit.py b/tools/validate-commit.py index 833067ecac..55254e238f 100755 --- a/tools/validate-commit.py +++ b/tools/validate-commit.py @@ -141,6 +141,10 @@ for details. ''') return False + # Cherry-picking can add an extra newline, which we'll allow. + cp_line = '\n(cherry picked from commit' + body = body.replace('\n' + cp_line, cp_line) + try: cmd = ['git', 'stripspace'] newbody = subprocess.check_output(cmd, input=body, universal_newlines=True) @@ -184,7 +188,7 @@ def verify_merge_request(): m_r_url = '{}/projects/{}/merge_requests/{}'.format(gitlab_api_pfx, project_id, m_r_iid) req = urllib.request.Request(m_r_url) - # print('req', repr(req)) + # print('req', repr(req), m_r_url) with urllib.request.urlopen(req) as resp: resp_json = resp.read().decode('utf-8') # print('resp', resp_json) @@ -232,9 +236,8 @@ def main(): if exit_code: print_git_user_instructions() - # Cherry-picking might add extra newlines, so skip this for now. - # if not verify_body(body): - # exit_code = 1 + if not verify_body(body): + exit_code = 1 if not verify_merge_request(): exit_code = 1