Skip to content

Commit

Permalink
fix: 如果拉取请求关闭则不进行任何操作
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 committed Dec 31, 2024
1 parent bdc4978 commit c4dda63
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/plugins/github/handlers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ async def merge_pull_request(
async def update_pull_request_status(self, title: str, branch_name: str):
"""拉取请求若为草稿状态则标记为可评审,若标题不符则修改标题"""
pull = await self.get_pull_request_by_branch(branch_name)
# 若拉取请求已关闭,则不进行任何操作
if pull.state == "closed":
return
if pull.title != title:
await self.update_pull_request_title(title, pull.number)
if pull.draft:
Expand Down
7 changes: 3 additions & 4 deletions src/plugins/github/plugins/publish/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ async def ensure_issue_plugin_test_button_in_progress(handler: IssueHandler):
async def process_pull_request(
handler: IssueHandler, result: ValidationDict, branch_name: str, title: str
):
"""
根据发布信息合法性创建拉取请求或将请求改为草稿
"""
"""根据发布信息合法性创建拉取请求或将请求改为草稿"""
if not result.valid:
# 如果之前已经创建了拉取请求,则将其转换为草稿
await handler.draft_pull_request(branch_name)
Expand Down Expand Up @@ -238,10 +236,11 @@ async def process_pull_request(
await handler.add_labels(pull_number, [PUBLISH_LABEL, result.type.value])
return
except RequestFailed:
# 如果之前已经创建了拉取请求,则将其转换为可评审
logger.info("该分支的拉取请求已创建,请前往查看")
else:
logger.info("远程分支已存在,跳过创建拉取请求")

# 如果之前已经创建了拉取请求,则将其转换为可评审
await handler.update_pull_request_status(title, branch_name)


Expand Down
3 changes: 1 addition & 2 deletions tests/plugins/github/publish/process/test_publish_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2021,8 +2021,7 @@ async def test_comment_immediate_after_pull_request_closed(
mock_list_comments_resp.parsed_data = [mock_comment]

mock_pull = mocker.MagicMock()
mock_pull.title = "Bot: test"
mock_pull.draft = False
mock_pull.state = "closed"
mock_pulls_resp = mocker.MagicMock()
mock_pulls_resp.parsed_data = [mock_pull]

Expand Down

0 comments on commit c4dda63

Please sign in to comment.