slack: capitalized some titles, added branch info
This commit is contained in:
parent
89218cd110
commit
25292a6e92
1 changed files with 15 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue