From e55a3d891af0367a6ee9a73fd058d55849defc9c Mon Sep 17 00:00:00 2001 From: Andrey Devyatkin Date: Fri, 10 Sep 2021 21:34:23 +0200 Subject: [PATCH] polishing messages Signed-off-by: Andrey Devyatkin --- helpers_git.py | 5 +++-- main.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/helpers_git.py b/helpers_git.py index a29838a..770d866 100644 --- a/helpers_git.py +++ b/helpers_git.py @@ -7,9 +7,10 @@ def resolve_git_ref_to_sha1(ref_name): return sha1 -def get_commit_message_for_ref(ref_name): +def get_commit_message_for_ref(ref_name, subject_only=True): print(f'Getting commit message for {ref_name}...') - msg = subprocess.getoutput(f'git log -n1 --pretty=tformat:%s%b {ref_name}') + format='%s' if subject_only else '%s\n%b' + msg = subprocess.getoutput(f'git log -n1 --pretty=tformat:{format} {ref_name}') print(f'Message = {msg}') return msg diff --git a/main.py b/main.py index 75008fd..e3ecd9d 100644 --- a/main.py +++ b/main.py @@ -35,14 +35,15 @@ author_id = author_slack_id if author_slack_id is not None else author_email commit_msg = helpers_git.get_commit_message_for_ref(current_commit_id) - text_for_request = f'Job `{build_job_name}` requires approval to proceed.\n' + text_for_request = f'Job `{build_job_name}` requires approval to proceed.\n\n' text_for_request += 'If approved will promote commit(s) below to branch ' text_for_request += ' and '.join(f'`{branch}`' for branch in branches_to_promote) text_for_request += f' in repository `{repo_name}`' text_for_request += f'\nThis message will self-destruct 🕶️🧨💥 and job will be auto-cancel in {timeout_minutes} minutes if no action is taken.\n\n' text_for_request += 'Details:\n' text_for_request += f'Job URL: {build_job_url}\n' - text_for_request += f'Commit message: `{commit_msg}`; commit id `{current_commit_id}`\n\n' + text_for_request += f'Commit message: `{commit_msg}`\n' + text_for_request += f'Commit id: `{current_commit_id}`\n' text_for_request += f'Committer: <@{commiter_id}>\n' text_for_request += f'Author: <@{author_id}>\n\n'