Skip to content

Commit

Permalink
support auto issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoYangyang0403 committed Sep 19, 2023
1 parent 35b41d9 commit 1c1a78c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
12 changes: 12 additions & 0 deletions lyrebird/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import socket
import threading
import traceback
import imp
from pathlib import Path

from packaging.version import parse as vparse
Expand Down Expand Up @@ -197,6 +198,17 @@ def run(args: argparse.Namespace):
# Mock mush init after other servers
application.server['mock'] = LyrebirdMockServer()

conf_autoissue = application.config.get('autoissue', False)
if conf_autoissue:
bugit_workspace = application.config.get('bugit.workspace', '')
bugit_default_template = application.config.get('bugit.default_template', '')
template_path = Path(bugit_workspace + bugit_default_template)
if bugit_workspace and bugit_default_template and template_path.exists():
template = imp.load_source(Path(template_path).stem, str(template_path))
application.server['issue'] = template.AutoIssueServer()
else:
logger.error(f'Init Auto Issue Server Failed. Template path is configured incorrectly: {template_path}')

# handle progress message
application.process_status_listener()

Expand Down
16 changes: 13 additions & 3 deletions lyrebird/notice_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
from lyrebird import log
from lyrebird import application
from lyrebird.mock import context
from copy import deepcopy

logger = log.get_logger()

class NoticeCenter():

def __init__(self):
self.checker_switch = application.config.get('autoissue.checker.switch', {})
self.HISTORY_NOTICE = None
self.notice_hashmap = {}
self.notice_list = []
Expand Down Expand Up @@ -69,14 +71,22 @@ def load_history_notice(self):
logger.error('Load history notice fail!')
traceback.print_exc()

def new_notice(self, msg):
def new_notice(self, msg_origin):
"""
display new notice
msg: message dict
msg_origin: message dict
"""
msg = deepcopy(msg_origin)
alert = True
# if notice need to be issued automatically, no alert
sender_file = msg.get('sender', {}).get('file', '')
if sender_file in self.checker_switch:
msg['title'] = f"[AutoIssue] {msg.get('title')}"
alert = False

unique_key = msg.get('title')
if self.notice_hashmap.get(unique_key):
self.notice_hashmap[unique_key]['noticeList'].append(msg)
Expand All @@ -86,7 +96,7 @@ def new_notice(self, msg):
self.notice_hashmap.update(
{
unique_key: {
'alert': True,
'alert': alert,
'noticeList': [msg]
}
}
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (2, 19, 1)
IVERSION = (2, 20, 0)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit 1c1a78c

Please sign in to comment.