Have different message when a closed PR is merged or not by toffentoffen · Pull Request #26 · Teamwork/github-sync · GitHub
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
4 changes: 4 additions & 0 deletions src/github.sh
16 changes: 12 additions & 4 deletions src/teamwork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,19 @@ teamwork::pull_request_closed() {
local -r user=$(github::get_sender_user)
local -r pr_url=$(github::get_pr_url)
local -r pr_title=$(github::get_pr_title)
local -r pr_merged=$(github::get_pr_merged)
Comment thread
toffentoffen marked this conversation as resolved.

teamwork::add_comment "
**$user** merged a PR: **$pr_title**
[$pr_url]($pr_url)
"
if [ "$pr_merged" == "true" ]; then
teamwork::add_comment "
**$user** merged a PR: **$pr_title**
[$pr_url]($pr_url)
"
else
teamwork::add_comment "
**$user** closed a PR without merging: **$pr_title**
[$pr_url]($pr_url)
"
fi
}

teamwork::pull_request_review_submitted() {
Expand Down
18 changes: 18 additions & 0 deletions tests/events/pull_request_closed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"action": "closed",
"number": 1,
"pull_request": {
"body": "This is the body of the PR. https://xxxx.teamwork.com/#/tasks/123 https://xxx.teamwork.com/#/tasks/456",
"head": {
"repo": {
"full_name": "teamwork/github-sync"
}
},
"html_url": "https://github.com/teamwork/github-sync/pull/1",
"title": "This is an example of a title for the PR.",
"merged": false
},
"sender": {
"login": "username"
}
}
4 changes: 2 additions & 2 deletions tests/events/pull_request_merged.json