Skip to content

Commit

Permalink
Add link to all actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukany committed Apr 7, 2021
1 parent 6f4d3c9 commit cd8bf46
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Supported actions:

- *open*: includes link with title, event author, mentions of assignees
and description
- *approved*: includes event author
- *update of assigness*: includes event author, list of previous assigness
and mentions of current assignees
- *merged*: includes action author
- *approved*: includes link and event author
- *update of assigness*: includes link, event author, list of previous
assigness and mentions of current assignees
- *merged*: includes link and action author
10 changes: 7 additions & 3 deletions ggci/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def from_dict(cls, event_dict: Dict[str, Any]) -> MergeRequestEvent:
def long_link(self) -> str:
return f'<{self.url}|!{self.mr_iid} *{self.title}*>'

@property
def short_link(self) -> str:
return f'<{self.url}|!{self.mr_iid}>'

def create_message(self) -> Message:

if self.action == Action.OPEN:
Expand All @@ -106,9 +110,9 @@ def create_message(self) -> Message:
)
)
elif self.action == Action.APPROVED:
text = f'*Approved* by {self.event_author}.'
text = f'{self.short_link} *approved* by {self.event_author}.'
elif self.action == Action.MERGE:
text = f'*Merged* by {self.event_author}.'
text = f'{self.short_link} *merged* by {self.event_author}.'
elif self.action == Action.UPDATE:
assert isinstance(self.assignees_change, AssigneesChange)
previous = format_users(users=self.assignees_change.previous)
Expand All @@ -117,7 +121,7 @@ def create_message(self) -> Message:
)
text = '\n'.join(
(
f'*Reassigned* by {self.event_author}',
f'{self.short_link} *reassigned* by {self.event_author}',
f'\tPrevious assignees: {previous}',
f'\tCurrent assignees: {current}',
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ggci"
version = "0.1.0"
version = "0.1.1"
description = "GitLab Google Chat Integration"
authors = [
"Jan Lukány <lukany.jan@gmail.com>",
Expand Down
Binary file modified showcase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions tests/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def test_update(payload_mr_update: MergeRequestEvent, monkeypatch):
monkeypatch.setattr(commons, '_get_google_chat_id', user_mappings.get)
message = mr_event.create_message()

assert '*Reassigned*' in message.text
assert (
'<https://www.gitlab.com/lukany/ggci|!42> *reassigned*' in message.text
)
assert 'by Chuck Norris' in message.text
assert '\tPrevious assignees: Alice, Bob' in message.text
assert '\tCurrent assignees: Carl, <users/1004>' in message.text
Expand All @@ -30,10 +32,15 @@ def test_update(payload_mr_update: MergeRequestEvent, monkeypatch):
def test_approved(payload_mr_approved: MergeRequestEvent):
mr_event = MergeRequestEvent.from_dict(payload_mr_approved)
message = mr_event.create_message()
assert message.text == '*Approved* by Chuck Norris.'
assert message.text == (
'<https://www.gitlab.com/lukany/ggci|!42> *approved* by Chuck Norris.'
)


def test_merge(payload_mr_merge: MergeRequestEvent):
mr_event = MergeRequestEvent.from_dict(payload_mr_merge)
message = mr_event.create_message()
assert message.text == '*Merged* by Chuck Norris.'
assert (
message.text
== '<https://www.gitlab.com/lukany/ggci|!42> *merged* by Chuck Norris.'
)

0 comments on commit cd8bf46

Please sign in to comment.