Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ data class PullRequest(
val title: String,
val body: String? = null,
val user: User,
val merged: Boolean? = false,
val number: Int
val number: Int,
val additions: Int = 0,
val deletions: Int = 0,
val draft: Boolean = false,
val merged: Boolean? = false
)
6 changes: 5 additions & 1 deletion src/main/kotlin/com/wire/github/response/model/Review.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ data class Review(
val body: String? = null,
val user: User,
val state: String
)
) {
val approved: Boolean get() = state.equals("approved", ignoreCase = true)
val changesRequested: Boolean get() = state.equals("changes_requested", ignoreCase = true)
val commented: Boolean get() = state.equals("commented", ignoreCase = true)
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/wire/github/util/TemplateHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TemplateHandler {
populateTemplate(
mustache = template,
model = response
)
)?.takeIf { it.isNotBlank() }
} catch (exception: MustacheNotFoundException) {
logger.error("MustacheNotFoundException: $exception")
null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
**[{{repository.fullName}}]** New comment on commit {{comment.id}}
{{! Fired on the "commit_comment" event (action=created): a comment left directly on a commit via GitHub's commit view. This is NOT a PR review comment and NOT an issue/PR conversation comment. }}
**@{{comment.user.login}}** [commented on a commit]({{comment.htmlUrl}}):

**Comment on line {{comment.line}} by {{comment.user.login}}**
{{{comment.body}}}

[comment]({{comment.htmlUrl}})
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**[{{repository.fullName}}]** New comment by **{{sender.login}}** on issue **{{{issue.title}}}**
{{! Fired on the "issue_comment" event (action=created). }}
{{! This also fires for top-level comments on Pull Requests, because GitHub models a PR's conversation timeline as an issue. }}
{{! It does not fire for inline diff-line review comments — those are pull_request_review_comment events, which we intentionally do not notify on. }}
**{{{issue.title}}}**
**@{{comment.user.login}}** [commented]({{comment.htmlUrl}}):

{{{comment.body}}}

[comment]({{comment.htmlUrl}})
7 changes: 3 additions & 4 deletions src/main/resources/templates/en/issues.closed.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
**[{{repository.fullName}}]** Issue **{{{issue.title}}}** {{action}} by **{{sender.login}}**

[issue]({{issue.htmlUrl}})
{{! Fired on the "issues" event (action=closed): an issue — never a pull request — was closed. }}
{{! Closing or merging a PR comes through pull_request.closed instead. }}
[**{{{issue.title}}}**]({{issue.htmlUrl}}) {{action}} by **@{{sender.login}}**
6 changes: 2 additions & 4 deletions src/main/resources/templates/en/issues.opened.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
**[{{repository.fullName}}]** Issue **{{{issue.title}}}** {{action}} by **{{issue.user.login}}**
{{! Fired on the "issues" event (action=opened): a new issue (never a pull request) was created. }}
[**{{{issue.title}}}**]({{issue.htmlUrl}}) {{action}} by **@{{issue.user.login}}**

{{{issue.body}}}

[issue]({{issue.htmlUrl}})
6 changes: 2 additions & 4 deletions src/main/resources/templates/en/issues.reopened.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
**[{{repository.fullName}}]** Issue **{{{issue.title}}}** {{action}} by **{{sender.login}}**
{{! Fired on the "issues" event (action=reopened): a previously closed issue (never a pull request) was reopened. }}
[**{{{issue.title}}}**]({{issue.htmlUrl}}) {{action}} by **@{{sender.login}}**

{{{issue.body}}}

{{issue.htmlUrl}}
13 changes: 3 additions & 10 deletions src/main/resources/templates/en/pull_request.closed.template
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
{{#pullRequest.merged}}
🚀 **Pull Request Merged!** by **{{ pullRequest.user.login }}**
{{/pullRequest.merged}}
{{^pullRequest.merged}}
❌ **Pull Request Closed!** by **{{ pullRequest.user.login }}**
{{/pullRequest.merged}}

📦 **Repository:** {{repository.fullName}}
🔖 **Title:** {{pullRequest.title}}
🔗 **PR Link:** [#{{pullRequest.number}}]({{pullRequest.htmlUrl}})
{{! Fired on the "pull_request" event (action=closed). }}
{{! GitHub uses action=closed for BOTH merged and merely-closed PRs, so this template branches on pullRequest.merged to tell them apart. }}
[**{{{pullRequest.title}}}**]({{pullRequest.htmlUrl}}): {{#pullRequest.merged}}🚀 **Merged**{{/pullRequest.merged}}{{^pullRequest.merged}}❌ **Closed**{{/pullRequest.merged}} by **@{{sender.login}}**
11 changes: 7 additions & 4 deletions src/main/resources/templates/en/pull_request.opened.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
🟢 **New Pull Request Opened!** by **{{pullRequest.user.login}}**
{{! Fired on the "pull_request" event (action=opened): a PR was newly opened. }}
{{! Gated on NOT draft: a PR opened directly as a draft renders nothing and sends no notification. It is announced later by pull_request.ready_for_review.template when the draft is marked ready. }}
{{! The reopened action (action=reopened) has no template and is intentionally silent. }}
{{^pullRequest.draft}}
[**{{pullRequest.title}}**]({{pullRequest.htmlUrl}}) (+{{pullRequest.additions}}/-{{pullRequest.deletions}}) by **@{{pullRequest.user.login}}**

📦 **Repository:** {{repository.fullName}}
🔖 **Title:** {{pullRequest.title}}
🔗 **PR Link:** [#{{pullRequest.number}}]({{pullRequest.htmlUrl}})
{{{pullRequest.body}}}
{{/pullRequest.draft}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{! Fired on the "pull_request" event (action=ready_for_review): a draft PR was marked ready for review. }}
{{! Mirrors pull_request.opened so a PR that started as a draft is still announced once — at the moment it becomes ready, rather than when it was first opened as a draft. }}
[**{{pullRequest.title}}**]({{pullRequest.htmlUrl}}) (+{{pullRequest.additions}}/-{{pullRequest.deletions}}) by **@{{pullRequest.user.login}}**

{{{pullRequest.body}}}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{#review.body}}**[{{repository.fullName}}]** Pull request review **{{pullRequest.title}}** was {{action}} by **{{review.user.login}}**

{{! Fired on the "pull_request_review" event: a reviewer finished a review via "Review changes". }}
{{! SURPRISE: a bare Approve carries no body, so only the prefix line renders. }}
{{! Any inline diff-line comments made in the same review arrive as separate pull_request_review_comment events, which we intentionally do not notify on. }}
[**{{{pullRequest.title}}}**]({{pullRequest.htmlUrl}}): {{#review.approved}}✅ **Approved** by {{/review.approved}}{{#review.changesRequested}}🔴 **Changes requested** by {{/review.changesRequested}} **@{{review.user.login}}** {{#review.commented}}Commented{{/review.commented}}
{{#review.body}}
{{{review.body}}}

[pull request]({{pullRequest.htmlUrl}})
—{{/review.body}}
{{/review.body}}

This file was deleted.

11 changes: 6 additions & 5 deletions src/main/resources/templates/en/push.template
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{{! Fired on the "push" event (no action segment): commits pushed to any branch or tag. }}
{{! Also fires for force-pushes and for branch/tag deletions. }}
{{! A deletion carries no commits, so the commits-empty guard below renders nothing for it. }}
{{^commits.isEmpty}}
**[{{repository.fullName}}]** Push by **{{sender.login}}**
**@{{sender.login}}** [pushed]({{compare}}) to **{{repository.fullName}}**:

{{#commits}}
- {{{message}}}
- {{{message}}}
{{/commits}}

[compare]({{compare}})
—{{/commits.isEmpty}}
{{/commits.isEmpty}}