Skip to content

Commit

Permalink
Add minimum length to source embed field
Browse files Browse the repository at this point in the history
I've added a minimum length to the source embed field to prevent it from
getting truncated to aggressively. Sometimes it's better to sacrifice a
newline if that means you actually get to see some information.
  • Loading branch information
SebastiaanZ committed Dec 5, 2020
1 parent 04797e3 commit d1cb23c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions github_status_embed/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import typing


MIN_EMBED_FIELD_LENGTH = 20


class MissingActionFile(FileNotFoundError):
"""Raised when the Action file can't be located."""

Expand Down Expand Up @@ -227,6 +230,7 @@ def shortened_source(self, length: int, owner: typing.Optional[str] = None) -> s
pr_source = pr_source.removeprefix(f"{owner}:")

# Truncate the `pr_source` if it's longer than the specified length
length = length if length >= MIN_EMBED_FIELD_LENGTH else MIN_EMBED_FIELD_LENGTH
if len(pr_source) > length:
stop = length - 3
pr_source = f"{pr_source[:stop]}..."
Expand Down

0 comments on commit d1cb23c

Please sign in to comment.