diff --git a/src/github.sh b/src/github.sh index 84266a09..d806c865 100644 --- a/src/github.sh +++ b/src/github.sh @@ -28,6 +28,10 @@ github::get_pr_title() { jq --raw-output .pull_request.title "$GITHUB_EVENT_PATH" } +github::get_pr_patch_stats() { + jq --raw-output '.pull_request | "\(.commits) \(.changed_files) \(.additions) \(.deletions)"' "$GITHUB_EVENT_PATH" +} + github::get_pr_merged() { jq --raw-output .pull_request.merged "$GITHUB_EVENT_PATH" } diff --git a/src/teamwork.sh b/src/teamwork.sh index fc0a238d..c0d1e4d4 100644 --- a/src/teamwork.sh +++ b/src/teamwork.sh @@ -36,10 +36,16 @@ teamwork::pull_request_opened() { local -r pr_url=$(github::get_pr_url) local -r pr_title=$(github::get_pr_title) local -r user=$(github::get_sender_user) + local -r pr_stats=$(github::get_pr_patch_stats) + IFS=" " read -r -a pr_stats_array <<< "$pr_stats" teamwork::add_comment " - **$user** opened a PR: **$pr_title** - [$pr_url]($pr_url) +**$user** opened a PR: **$pr_title** +[$pr_url]($pr_url) + +--- + +🔢 ${pr_stats_array[0]} commits / 📝 ${pr_stats_array[1]} files updated / ${pr_stats_array[2]} additions / ${pr_stats_array[3]} deletions " } @@ -74,7 +80,9 @@ teamwork::pull_request_review_submitted() { teamwork::add_comment " **$user** submitted a review to the PR: **$pr_title** [$pr_url]($pr_url) + --- + Review: **$review_state** $comment " diff --git a/tests/events/pull_request_opened.json b/tests/events/pull_request_opened.json index 2f5b8423..7931dbfb 100644 --- a/tests/events/pull_request_opened.json +++ b/tests/events/pull_request_opened.json @@ -9,7 +9,11 @@ } }, "html_url": "https://github.com/teamwork/github-sync/pull/1", - "title": "This is an example of a title for the PR." + "title": "This is an example of a title for the PR.", + "commits": 1, + "additions": 2, + "deletions": 3, + "changed_files": 4 }, "sender": { "login": "username"