Skip to content

Commit

Permalink
Add: Allow to get commit message from git log
Browse files Browse the repository at this point in the history
If commit is set but not commit message, the git commit message is
gathered from git log now.
  • Loading branch information
bjoernricks committed Jul 19, 2023
1 parent af8cc48 commit 225b2e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
10 changes: 8 additions & 2 deletions mattermost_notify/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pathlib import Path
from typing import Any, Optional

from pontos.git import Git
from pontos.terminal import RichTerminal

from mattermost_notify.errors import MattermostNotifyError
Expand Down Expand Up @@ -103,11 +104,16 @@ def fill_template(

if commit:
commit_url = f"{repository_url}/commit/{commit}"

if not commit_message:
commit_message = Git().show(
format="format:%s", patch=False, objects=commit # type: ignore[assignment] # noqa: E501
)
else:
commit_url = f'{repository_url}/commit/{head_commit.get("id", "")}'

if not commit_message:
commit_message = head_commit.get("message", "").split("\n", 1)[0]
if not commit_message:
commit_message = head_commit.get("message", "").split("\n", 1)[0]

highlight_str = ""
if highlight and workflow_status is not Status.SUCCESS:
Expand Down
22 changes: 11 additions & 11 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ include = [

[tool.poetry.dependencies]
python = ">=3.9"
pontos = ">=22.7.0"
pontos = ">=22.7.7"
httpx = ">=0.23.1"

[tool.poetry.dev-dependencies]
Expand Down

0 comments on commit 225b2e9

Please sign in to comment.