@@ -32,6 +32,38 @@ teamwork::add_comment() {
3232 log::message " $response "
3333}
3434
35+ teamwork::add_tag () {
36+ local -r tag_name=$1
37+
38+ if [ " $ENV " == " test" ]; then
39+ log::message " Test - Simulate request. Task ID: $TEAMWORK_TASK_ID - Tag: ${tag_name// \" / } "
40+ return
41+ fi
42+
43+ response=$( curl -X " PUT" " $TEAMWORK_URI /projects/api/v1/tasks/$TEAMWORK_TASK_ID /tags.json" \
44+ -u " $TEAMWORK_API_TOKEN " ' :' \
45+ -H ' Content-Type: application/json; charset=utf-8' \
46+ -d " { \" tags\" : { \" content\" : \" ${tag_name// \" / } \" } }" )
47+
48+ log::message " $response "
49+ }
50+
51+ teamwork::remove_tag () {
52+ local -r tag_name=$1
53+
54+ if [ " $ENV " == " test" ]; then
55+ log::message " Test - Simulate request. Task ID: $TEAMWORK_TASK_ID - Tag: ${tag_name// \" / } "
56+ return
57+ fi
58+
59+ response=$( curl -X " PUT" " $TEAMWORK_URI /projects/api/v1/tasks/$TEAMWORK_TASK_ID /tags.json" \
60+ -u " $TEAMWORK_API_TOKEN " ' :' \
61+ -H ' Content-Type: application/json; charset=utf-8' \
62+ -d " { \" tags\" : { \" content\" : \" ${tag_name// \" / } \" },\" removeProvidedTags\" :\" true\" }" )
63+
64+ log::message " $response "
65+ }
66+
3567teamwork::pull_request_opened () {
3668 local -r pr_url=$( github::get_pr_url)
3769 local -r pr_title=$( github::get_pr_title)
@@ -49,6 +81,8 @@ teamwork::pull_request_opened() {
4981
5082🔢 ${pr_stats_array[0]} commits / 📝 ${pr_stats_array[1]} files updated / ${pr_stats_array[2]} additions / ${pr_stats_array[3]} deletions
5183 "
84+
85+ teamwork::add_tag " PR Open"
5286}
5387
5488teamwork::pull_request_closed () {
@@ -62,11 +96,14 @@ teamwork::pull_request_closed() {
6296**$user ** merged a PR: **$pr_title **
6397[$pr_url ]($pr_url )
6498"
99+ teamwork::add_tag " PR Merged"
100+ teamwork::remove_tag " PR Open"
65101 else
66102 teamwork::add_comment "
67103**$user ** closed a PR without merging: **$pr_title **
68104[$pr_url ]($pr_url )
69105"
106+ teamwork::remove_tag " PR Open"
70107 fi
71108}
72109
0 commit comments