diff --git a/rhodecode/integrations/types/handlers/slack.py b/rhodecode/integrations/types/handlers/slack.py index db64d2aa..edd50a61 100644 --- a/rhodecode/integrations/types/handlers/slack.py +++ b/rhodecode/integrations/types/handlers/slack.py @@ -128,9 +128,9 @@ class SlackDataHandler(CommitParsingDataHandler): template = Template( textwrap.dedent(r""" - *pull request title*: ${pr_title} + *Pull Request Title*: ${pr_title} % if status_text: - *submitted status*: `${status_text}` + *Submitted Status*: `${status_text}` % endif >>> ${comment_text} """) @@ -156,7 +156,7 @@ class SlackDataHandler(CommitParsingDataHandler): template = Template( textwrap.dedent(r""" - *pull request title*: ${pr_title} + *Pull Request Title*: ${pr_title} """) ) text = render_with_traceback(template, pr_title=data["pullrequest"]["title"]) @@ -174,6 +174,12 @@ class SlackDataHandler(CommitParsingDataHandler): events.PullRequestCreateEvent: "created", }.get(event.__class__, str(event.__class__)) + # Extract branch information + pullrequest = event.pullrequest + source_branch = pullrequest.source_ref_parts.name if pullrequest.source_ref_parts else "unknown" + target_branch = pullrequest.target_ref_parts.name if pullrequest.target_ref_parts else "unknown" + branch_info = f"{source_branch} → {target_branch}" + template = Template( textwrap.dedent(r""" *${data['actor']['username']}* `${action}` pull request <${data['pullrequest']['url']}|#${data['pullrequest']['pull_request_id']}>: @@ -183,13 +189,16 @@ class SlackDataHandler(CommitParsingDataHandler): template = Template( textwrap.dedent(r""" - *pull request title*: ${pr_title} + ${branch_info} + *Title*: ${pr_title} %if data['pullrequest']['commits']: - *commits*: ${len(data['pullrequest']['commits'])} + *Commits*: ${len(data['pullrequest']['commits'])} %endif """) ) - text = render_with_traceback(template, pr_title=data["pullrequest"]["title"], data=data) + text = render_with_traceback( + template, pr_title=data["pullrequest"]["title"], data=data, branch_info=branch_info + ) slack_data.title = title slack_data.text = text