Improve github hooks messages
parent
9fcd418a4d
commit
3e032622e3
|
@ -13,6 +13,7 @@
|
||||||
- Add traditional chinese (zh-Hant) translation.
|
- Add traditional chinese (zh-Hant) translation.
|
||||||
- Add Jitsi to our supported videoconference apps list
|
- Add Jitsi to our supported videoconference apps list
|
||||||
- Add tags field to CSV reports.
|
- Add tags field to CSV reports.
|
||||||
|
- Improve history (and email) comments created by all the GitHub actions
|
||||||
|
|
||||||
### Misc
|
### Misc
|
||||||
- New contrib plugin for letschat (by Δndrea Stagi)
|
- New contrib plugin for letschat (by Δndrea Stagi)
|
||||||
|
|
|
@ -36,14 +36,13 @@ class PushEventHook(BaseEventHook):
|
||||||
if self.payload is None:
|
if self.payload is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
github_user = self.payload.get('sender', {}).get('id', None)
|
github_user = self.payload.get('sender', {})
|
||||||
|
|
||||||
commits = self.payload.get("commits", [])
|
commits = self.payload.get("commits", [])
|
||||||
for commit in commits:
|
for commit in commits:
|
||||||
message = commit.get("message", None)
|
self._process_commit(commit, github_user)
|
||||||
self._process_message(message, github_user)
|
|
||||||
|
|
||||||
def _process_message(self, message, github_user):
|
def _process_commit(self, commit, github_user):
|
||||||
"""
|
"""
|
||||||
The message we will be looking for seems like
|
The message we will be looking for seems like
|
||||||
TG-XX #yyyyyy
|
TG-XX #yyyyyy
|
||||||
|
@ -51,6 +50,8 @@ class PushEventHook(BaseEventHook):
|
||||||
XX: is the ref for us, issue or task
|
XX: is the ref for us, issue or task
|
||||||
yyyyyy: is the status slug we are setting
|
yyyyyy: is the status slug we are setting
|
||||||
"""
|
"""
|
||||||
|
message = commit.get("message", None)
|
||||||
|
|
||||||
if message is None:
|
if message is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -59,9 +60,9 @@ class PushEventHook(BaseEventHook):
|
||||||
if m:
|
if m:
|
||||||
ref = m.group(1)
|
ref = m.group(1)
|
||||||
status_slug = m.group(2)
|
status_slug = m.group(2)
|
||||||
self._change_status(ref, status_slug, github_user)
|
self._change_status(ref, status_slug, github_user, commit)
|
||||||
|
|
||||||
def _change_status(self, ref, status_slug, github_user):
|
def _change_status(self, ref, status_slug, github_user, commit):
|
||||||
if Issue.objects.filter(project=self.project, ref=ref).exists():
|
if Issue.objects.filter(project=self.project, ref=ref).exists():
|
||||||
modelClass = Issue
|
modelClass = Issue
|
||||||
statusClass = IssueStatus
|
statusClass = IssueStatus
|
||||||
|
@ -84,9 +85,31 @@ class PushEventHook(BaseEventHook):
|
||||||
element.status = status
|
element.status = status
|
||||||
element.save()
|
element.save()
|
||||||
|
|
||||||
|
github_user_id = github_user.get('id', None)
|
||||||
|
github_user_name = github_user.get('login', None)
|
||||||
|
github_user_url = github_user.get('html_url', None)
|
||||||
|
commit_id = commit.get("id", None)
|
||||||
|
commit_url = commit.get("url", None)
|
||||||
|
commit_message = commit.get("message", None)
|
||||||
|
|
||||||
|
if (github_user_id and github_user_name and github_user_url and
|
||||||
|
commit_id and commit_url and commit_message):
|
||||||
|
comment = _("Status changed by [@{github_user_name}]({github_user_url} "
|
||||||
|
"\"See @{github_user_name}'s GitHub profile\") "
|
||||||
|
"from GitHub commit [#{commit_id}]({commit_url} "
|
||||||
|
"\"See commit '#{commit_id}: {commit_message}'\").").format(
|
||||||
|
github_user_name=github_user_name,
|
||||||
|
github_user_url=github_user_url,
|
||||||
|
commit_id=commit_id[:7],
|
||||||
|
commit_url=commit_url,
|
||||||
|
commit_message=commit_message)
|
||||||
|
|
||||||
|
else:
|
||||||
|
comment = _("Status changed from GitHub commit.")
|
||||||
|
|
||||||
snapshot = take_snapshot(element,
|
snapshot = take_snapshot(element,
|
||||||
comment=_("Status changed from GitHub commit"),
|
comment=comment,
|
||||||
user=get_github_user(github_user))
|
user=get_github_user(github_user_id))
|
||||||
send_notifications(element, history=snapshot)
|
send_notifications(element, history=snapshot)
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,11 +126,17 @@ class IssuesEventHook(BaseEventHook):
|
||||||
if self.payload.get('action', None) != "opened":
|
if self.payload.get('action', None) != "opened":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
number = self.payload.get('issue', {}).get('number', None)
|
||||||
subject = self.payload.get('issue', {}).get('title', None)
|
subject = self.payload.get('issue', {}).get('title', None)
|
||||||
description = self.payload.get('issue', {}).get('body', None)
|
|
||||||
github_url = self.payload.get('issue', {}).get('html_url', None)
|
github_url = self.payload.get('issue', {}).get('html_url', None)
|
||||||
github_user = self.payload.get('issue', {}).get('user', {}).get('id', None)
|
github_user_id = self.payload.get('issue', {}).get('user', {}).get('id', None)
|
||||||
|
github_user_name = self.payload.get('issue', {}).get('user', {}).get('login', None)
|
||||||
|
github_user_url = self.payload.get('issue', {}).get('user', {}).get('html_url', None)
|
||||||
project_url = self.payload.get('repository', {}).get('html_url', None)
|
project_url = self.payload.get('repository', {}).get('html_url', None)
|
||||||
|
description = self.payload.get('issue', {}).get('body', None)
|
||||||
|
description = replace_github_references(project_url, description)
|
||||||
|
|
||||||
|
user = get_github_user(github_user_id)
|
||||||
|
|
||||||
if not all([subject, github_url, project_url]):
|
if not all([subject, github_url, project_url]):
|
||||||
raise ActionSyntaxException(_("Invalid issue information"))
|
raise ActionSyntaxException(_("Invalid issue information"))
|
||||||
|
@ -115,17 +144,31 @@ class IssuesEventHook(BaseEventHook):
|
||||||
issue = Issue.objects.create(
|
issue = Issue.objects.create(
|
||||||
project=self.project,
|
project=self.project,
|
||||||
subject=subject,
|
subject=subject,
|
||||||
description=replace_github_references(project_url, description),
|
description=description,
|
||||||
status=self.project.default_issue_status,
|
status=self.project.default_issue_status,
|
||||||
type=self.project.default_issue_type,
|
type=self.project.default_issue_type,
|
||||||
severity=self.project.default_severity,
|
severity=self.project.default_severity,
|
||||||
priority=self.project.default_priority,
|
priority=self.project.default_priority,
|
||||||
external_reference=['github', github_url],
|
external_reference=['github', github_url],
|
||||||
owner=get_github_user(github_user)
|
owner=user
|
||||||
)
|
)
|
||||||
take_snapshot(issue, user=get_github_user(github_user))
|
take_snapshot(issue, user=user)
|
||||||
|
|
||||||
snapshot = take_snapshot(issue, comment=_("Created from GitHub"), user=get_github_user(github_user))
|
if number and subject and github_user_name and github_user_url:
|
||||||
|
comment = _("Issue created by [@{github_user_name}]({github_user_url} "
|
||||||
|
"\"See @{github_user_name}'s GitHub profile\") "
|
||||||
|
"from GitHub.\nOrigin GitHub issue: [{number}: {subject}]({github_url} "
|
||||||
|
"\"Go to '{number}: {subject}'\"):\n\n"
|
||||||
|
"{description}").format(github_user_name=github_user_name,
|
||||||
|
github_user_url=github_user_url,
|
||||||
|
number=number,
|
||||||
|
subject=subject,
|
||||||
|
github_url=github_url,
|
||||||
|
description=description)
|
||||||
|
else:
|
||||||
|
comment = _("Issue created from GitHub.")
|
||||||
|
|
||||||
|
snapshot = take_snapshot(issue, comment=comment, user=user)
|
||||||
send_notifications(issue, history=snapshot)
|
send_notifications(issue, history=snapshot)
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,12 +177,18 @@ class IssueCommentEventHook(BaseEventHook):
|
||||||
if self.payload.get('action', None) != "created":
|
if self.payload.get('action', None) != "created":
|
||||||
raise ActionSyntaxException(_("Invalid issue comment information"))
|
raise ActionSyntaxException(_("Invalid issue comment information"))
|
||||||
|
|
||||||
|
number = self.payload.get('issue', {}).get('number', None)
|
||||||
|
subject = self.payload.get('issue', {}).get('title', None)
|
||||||
github_url = self.payload.get('issue', {}).get('html_url', None)
|
github_url = self.payload.get('issue', {}).get('html_url', None)
|
||||||
comment_message = self.payload.get('comment', {}).get('body', None)
|
github_user_id = self.payload.get('sender', {}).get('id', None)
|
||||||
github_user = self.payload.get('sender', {}).get('id', None)
|
github_user_name = self.payload.get('sender', {}).get('login', None)
|
||||||
|
github_user_url = self.payload.get('sender', {}).get('html_url', None)
|
||||||
project_url = self.payload.get('repository', {}).get('html_url', None)
|
project_url = self.payload.get('repository', {}).get('html_url', None)
|
||||||
|
comment_message = self.payload.get('comment', {}).get('body', None)
|
||||||
comment_message = replace_github_references(project_url, comment_message)
|
comment_message = replace_github_references(project_url, comment_message)
|
||||||
|
|
||||||
|
user = get_github_user(github_user_id)
|
||||||
|
|
||||||
if not all([comment_message, github_url, project_url]):
|
if not all([comment_message, github_url, project_url]):
|
||||||
raise ActionSyntaxException(_("Invalid issue comment information"))
|
raise ActionSyntaxException(_("Invalid issue comment information"))
|
||||||
|
|
||||||
|
@ -148,7 +197,19 @@ class IssueCommentEventHook(BaseEventHook):
|
||||||
uss = UserStory.objects.filter(external_reference=["github", github_url])
|
uss = UserStory.objects.filter(external_reference=["github", github_url])
|
||||||
|
|
||||||
for item in list(issues) + list(tasks) + list(uss):
|
for item in list(issues) + list(tasks) + list(uss):
|
||||||
snapshot = take_snapshot(item,
|
if number and subject and github_user_name and github_user_url:
|
||||||
comment=_("From GitHub:\n\n{}".format(comment_message)),
|
comment = _("Comment by [@{github_user_name}]({github_user_url} "
|
||||||
user=get_github_user(github_user))
|
"\"See @{github_user_name}'s GitHub profile\") "
|
||||||
|
"from GitHub.\nOrigin GitHub issue: [{number}: {subject}]({github_url} "
|
||||||
|
"\"Go to '{number}: {subject}'\")\n\n"
|
||||||
|
"{message}").format(github_user_name=github_user_name,
|
||||||
|
github_user_url=github_user_url,
|
||||||
|
number=number,
|
||||||
|
subject=subject,
|
||||||
|
github_url=github_url,
|
||||||
|
message=comment_message)
|
||||||
|
else:
|
||||||
|
comment = _("Comment From GitHub:\n\n{message}").format(message=comment_message)
|
||||||
|
|
||||||
|
snapshot = take_snapshot(item, comment=comment, user=user)
|
||||||
send_notifications(item, history=snapshot)
|
send_notifications(item, history=snapshot)
|
||||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: taiga-back\n"
|
"Project-Id-Version: taiga-back\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2015-05-04 18:39+0200\n"
|
"POT-Creation-Date: 2015-05-06 15:07+0200\n"
|
||||||
"PO-Revision-Date: 2015-03-25 20:09+0100\n"
|
"PO-Revision-Date: 2015-03-25 20:09+0100\n"
|
||||||
"Last-Translator: Taiga Dev Team <support@taiga.io>\n"
|
"Last-Translator: Taiga Dev Team <support@taiga.io>\n"
|
||||||
"Language-Team: Taiga Dev Team <support@taiga.io>\n"
|
"Language-Team: Taiga Dev Team <support@taiga.io>\n"
|
||||||
|
@ -615,12 +615,12 @@ msgid "The payload is not valid"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/hooks/bitbucket/event_hooks.py:81
|
#: taiga/hooks/bitbucket/event_hooks.py:81
|
||||||
#: taiga/hooks/github/event_hooks.py:75 taiga/hooks/gitlab/event_hooks.py:74
|
#: taiga/hooks/github/event_hooks.py:76 taiga/hooks/gitlab/event_hooks.py:74
|
||||||
msgid "The referenced element doesn't exist"
|
msgid "The referenced element doesn't exist"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/hooks/bitbucket/event_hooks.py:88
|
#: taiga/hooks/bitbucket/event_hooks.py:88
|
||||||
#: taiga/hooks/github/event_hooks.py:82 taiga/hooks/gitlab/event_hooks.py:81
|
#: taiga/hooks/github/event_hooks.py:83 taiga/hooks/gitlab/event_hooks.py:81
|
||||||
msgid "The status doesn't exist"
|
msgid "The status doesn't exist"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -628,27 +628,58 @@ msgstr ""
|
||||||
msgid "Status changed from BitBucket commit"
|
msgid "Status changed from BitBucket commit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/hooks/github/event_hooks.py:88
|
#: taiga/hooks/github/event_hooks.py:97
|
||||||
msgid "Status changed from GitHub commit"
|
#, python-brace-format
|
||||||
|
msgid ""
|
||||||
|
"Status changed by [@{github_user_name}]({github_user_url} \"See "
|
||||||
|
"@{github_user_name}'s GitHub profile\") from GitHub commit [#{commit_id}]"
|
||||||
|
"({commit_url} \"See commit '#{commit_id}: {commit_message}'\")."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/hooks/github/event_hooks.py:113 taiga/hooks/gitlab/event_hooks.py:114
|
#: taiga/hooks/github/event_hooks.py:108
|
||||||
|
msgid "Status changed from GitHub commit."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: taiga/hooks/github/event_hooks.py:142 taiga/hooks/gitlab/event_hooks.py:114
|
||||||
msgid "Invalid issue information"
|
msgid "Invalid issue information"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/hooks/github/event_hooks.py:128
|
#: taiga/hooks/github/event_hooks.py:158
|
||||||
msgid "Created from GitHub"
|
#, python-brace-format
|
||||||
|
msgid ""
|
||||||
|
"Issue created by [@{github_user_name}]({github_user_url} \"See "
|
||||||
|
"@{github_user_name}'s GitHub profile\") from GitHub.\n"
|
||||||
|
"Origin GitHub issue: [{number}: {subject}]({github_url} \"Go to '{number}: "
|
||||||
|
"{subject}'\"):\n"
|
||||||
|
"\n"
|
||||||
|
"{description}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/hooks/github/event_hooks.py:135 taiga/hooks/github/event_hooks.py:144
|
#: taiga/hooks/github/event_hooks.py:169
|
||||||
|
msgid "Issue created from GitHub."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: taiga/hooks/github/event_hooks.py:178 taiga/hooks/github/event_hooks.py:193
|
||||||
msgid "Invalid issue comment information"
|
msgid "Invalid issue comment information"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/hooks/github/event_hooks.py:152
|
#: taiga/hooks/github/event_hooks.py:201
|
||||||
|
#, python-brace-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"From GitHub:\n"
|
"Comment by [@{github_user_name}]({github_user_url} \"See "
|
||||||
|
"@{github_user_name}'s GitHub profile\") from GitHub.\n"
|
||||||
|
"Origin GitHub issue: [{number}: {subject}]({github_url} \"Go to '{number}: "
|
||||||
|
"{subject}'\")\n"
|
||||||
"\n"
|
"\n"
|
||||||
"{}"
|
"{message}"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: taiga/hooks/github/event_hooks.py:212
|
||||||
|
#, python-brace-format
|
||||||
|
msgid ""
|
||||||
|
"Comment From GitHub:\n"
|
||||||
|
"\n"
|
||||||
|
"{message}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/hooks/gitlab/event_hooks.py:87
|
#: taiga/hooks/gitlab/event_hooks.py:87
|
||||||
|
@ -1920,48 +1951,48 @@ msgstr ""
|
||||||
msgid "Mail sended successful!"
|
msgid "Mail sended successful!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:134 taiga/users/api.py:139
|
#: taiga/users/api.py:133 taiga/users/api.py:138
|
||||||
msgid "Token is invalid"
|
msgid "Token is invalid"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:160
|
#: taiga/users/api.py:159
|
||||||
msgid "Current password parameter needed"
|
msgid "Current password parameter needed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:163
|
#: taiga/users/api.py:162
|
||||||
msgid "New password parameter needed"
|
msgid "New password parameter needed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:166
|
#: taiga/users/api.py:165
|
||||||
msgid "Invalid password length at least 6 charaters needed"
|
msgid "Invalid password length at least 6 charaters needed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:169
|
#: taiga/users/api.py:168
|
||||||
msgid "Invalid current password"
|
msgid "Invalid current password"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:185
|
#: taiga/users/api.py:184
|
||||||
msgid "Incomplete arguments"
|
msgid "Incomplete arguments"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:190
|
#: taiga/users/api.py:189
|
||||||
msgid "Invalid image format"
|
msgid "Invalid image format"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:243
|
#: taiga/users/api.py:242
|
||||||
msgid "Duplicated email"
|
msgid "Duplicated email"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:245
|
#: taiga/users/api.py:244
|
||||||
msgid "Not valid email"
|
msgid "Not valid email"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:265 taiga/users/api.py:271
|
#: taiga/users/api.py:264 taiga/users/api.py:270
|
||||||
msgid ""
|
msgid ""
|
||||||
"Invalid, are you sure the token is correct and you didn't use it before?"
|
"Invalid, are you sure the token is correct and you didn't use it before?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: taiga/users/api.py:298 taiga/users/api.py:306 taiga/users/api.py:309
|
#: taiga/users/api.py:297 taiga/users/api.py:305 taiga/users/api.py:308
|
||||||
msgid "Invalid, are you sure the token is correct?"
|
msgid "Invalid, are you sure the token is correct?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -2107,7 +2138,7 @@ msgid ""
|
||||||
" <p>We built it to be beautiful, elegant, simple to use and fun - "
|
" <p>We built it to be beautiful, elegant, simple to use and fun - "
|
||||||
"without forsaking flexibility and power.</p>\n"
|
"without forsaking flexibility and power.</p>\n"
|
||||||
" <small>The taiga Team</small>\n"
|
" <small>The taiga Team</small>\n"
|
||||||
" </td\n"
|
" </td>\n"
|
||||||
" "
|
" "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -337,15 +337,15 @@ def test_issue_comment_event_on_existing_issue_task_and_us(client):
|
||||||
|
|
||||||
issue_history = get_history_queryset_by_model_instance(issue)
|
issue_history = get_history_queryset_by_model_instance(issue)
|
||||||
assert issue_history.count() == 1
|
assert issue_history.count() == 1
|
||||||
assert issue_history[0].comment == "From GitHub:\n\nTest body"
|
assert "Test body" in issue_history[0].comment
|
||||||
|
|
||||||
task_history = get_history_queryset_by_model_instance(task)
|
task_history = get_history_queryset_by_model_instance(task)
|
||||||
assert task_history.count() == 1
|
assert task_history.count() == 1
|
||||||
assert task_history[0].comment == "From GitHub:\n\nTest body"
|
assert "Test body" in issue_history[0].comment
|
||||||
|
|
||||||
us_history = get_history_queryset_by_model_instance(us)
|
us_history = get_history_queryset_by_model_instance(us)
|
||||||
assert us_history.count() == 1
|
assert us_history.count() == 1
|
||||||
assert us_history[0].comment == "From GitHub:\n\nTest body"
|
assert "Test body" in issue_history[0].comment
|
||||||
|
|
||||||
assert len(mail.outbox) == 3
|
assert len(mail.outbox) == 3
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue