Skip to content

Commit

Permalink
fix assignee for release-helper (#37407)
Browse files Browse the repository at this point in the history
  • Loading branch information
msyyc authored Sep 14, 2024
1 parent 4396007 commit 86d97f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
19 changes: 6 additions & 13 deletions scripts/release_helper/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
class IssueProcess:
"""
# won't be changed anymore after __init__
request_repo_dict = {} # request repo instance generated by different token
owner = '' # issue owner
assignee_candidates = {} # assignee candidates who will be assigned to handle issue
language_owner = {} # language owner who may handle issue
Expand All @@ -48,10 +47,9 @@ class IssueProcess:
spec_repo = None # local swagger repo path
"""

def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Repository],
def __init__(self, issue_package: IssuePackage, request_repo: Repository,
assignee_candidates: Set[str], language_owner: Set[str]):
self.issue_package = issue_package
self.request_repo_dict = request_repo_dict
self.assignee = issue_package.issue.assignee.login if issue_package.issue.assignee else ''
self.owner = issue_package.issue.user.login
self.created_time = issue_package.issue.created_at
Expand All @@ -70,6 +68,7 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep
self.spec_repo = Path(os.getenv('SPEC_REPO'))
self.typespec_json = Path(os.getenv('TYPESPEC_JSON'))
self.language_name = "common"
self.request_repo = request_repo

@property
def for_typespec(self) -> bool:
Expand Down Expand Up @@ -257,11 +256,8 @@ def update_assignee(self, assignee_to_del: str, assignee_to_add: str) -> None:
def log(self, message: str) -> None:
_LOG.info(f'issue {self.issue_package.issue.number}: {message}')

def request_repo(self) -> Repository:
return self.request_repo_dict[self.assignee]

def update_issue_instance(self) -> None:
self.issue_package.issue = self.request_repo().get_issue(self.issue_package.issue.number)
self.issue_package.issue = self.request_repo.get_issue(self.issue_package.issue.number)

def auto_assign_policy(self) -> str:
assignees = list(self.assignee_candidates)
Expand Down Expand Up @@ -379,7 +375,7 @@ def run(self) -> None:
class Common:
""" The class defines some function for all languages to reference
issues_package = None # issues that need to handle
request_repo_dict = {} # request repo instance generated by different token
request_repo # request repo instance generated by token
assignee_candidates = {} # assignee candidates who will be assigned to handle issue
language_owner = {} # language owner who may handle issue
result = []
Expand All @@ -397,12 +393,9 @@ def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str],
self.date_from_target = ''
self.package_name = ''
self.result = []
self.request_repo_dict = {}
self.request_repo = Github(assignee_token).get_repo(REQUEST_REPO)
self.issue_process_function = IssueProcess

for assignee in self.assignee_candidates:
self.request_repo_dict[assignee] = Github(assignee_token).get_repo(REQUEST_REPO)

@staticmethod
def for_test():
return bool(os.getenv("TEST_ISSUE_NUMBER"))
Expand Down Expand Up @@ -439,7 +432,7 @@ def output_md(idx: int, item: IssueProcess):

def proc_issue(self):
for item in self.issues_package:
issue = self.issue_process_function(item, self.request_repo_dict, self.assignee_candidates,
issue = self.issue_process_function(item, self.request_repo, self.assignee_candidates,
self.language_owner)

try:
Expand Down
4 changes: 2 additions & 2 deletions scripts/release_helper/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

class IssueProcessPython(IssueProcess):

def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Repository],
def __init__(self, issue_package: IssuePackage, request_repo: Repository,
assignee_candidates: Set[str], language_owner: Set[str]):
IssueProcess.__init__(self, issue_package, request_repo_dict, assignee_candidates, language_owner)
IssueProcess.__init__(self, issue_package, request_repo, assignee_candidates, language_owner)
self.output_folder = '' # network of sdk/network/azure-mgmt-XXX
self.delay_time = self.get_delay_time()
self.python_tag = ''
Expand Down

0 comments on commit 86d97f6

Please sign in to comment.