Skip to content

Commit

Permalink
change: 修改提交消息的格式,在最后添加上议题编号
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 committed May 21, 2022
1 parent b75ceb6 commit 4d0582d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/
- 修复当议题关闭仍然创建拉取请求的问题
- 修复解决冲突时没有重置的问题

### Changed

- 修改提交消息的格式,在最后添加上议题编号

### Removed

- 移除插件加载验证
Expand All @@ -43,7 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/lang/zh-CN/

- 修复标签相关的报错

### Change
### Changed

- 使用自建的镜像以提升速度

Expand Down
2 changes: 1 addition & 1 deletion src/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def process_issues_event(repo: "Repository"):
run_shell_command(["git", "switch", "-C", branch_name])
# 更新文件并提交更改
info.update_file()
commit_and_push(info, branch_name)
commit_and_push(info, branch_name, issue.number)
# 创建拉取请求
create_pull_request(
repo, info, g.settings.input_config.base, branch_name, issue.number
Expand Down
9 changes: 4 additions & 5 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ def get_type_by_commit_message(message: str) -> Optional[PublishType]:
return PublishType.ADAPTER


def commit_and_push(info: PublishInfo, branch_name: str):
def commit_and_push(info: PublishInfo, branch_name: str, issue_number: int):
"""提交并推送"""
commit_message = (
f"{COMMIT_MESSAGE_PREFIX} {info.get_type().value.lower()} {info.name}"
)
commit_message = f"{COMMIT_MESSAGE_PREFIX} {info.get_type().value.lower()} {info.name} (#{issue_number})"

run_shell_command(["git", "config", "--global", "user.name", info.author])
user_email = f"{info.author}@users.noreply.github.com"
run_shell_command(["git", "config", "--global", "user.email", user_email])
Expand Down Expand Up @@ -153,7 +152,7 @@ def resolve_conflict_pull_requests(pulls: list["PullRequest"], repo: "Repository
info = extract_publish_info_from_issue(issue, publish_type)
if isinstance(info, PublishInfo):
info.update_file()
commit_and_push(info, pull.head.ref)
commit_and_push(info, pull.head.ref, issue_number)
logging.info("拉取请求更新完毕")
else:
logging.info("发布没通过检查,已跳过")
Expand Down
2 changes: 1 addition & 1 deletion tests/process/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_process_issues(mocker: MockerFixture, tmp_path: Path) -> None:
),
mocker.call(["git", "add", "-A"], check=True),
mocker.call(
["git", "commit", "-m", ":beers: publish bot test"], check=True
["git", "commit", "-m", ":beers: publish bot test (#1)"], check=True
),
mocker.call(["git", "push", "origin", "publish/issue1", "-f"], check=True),
]
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_resolve_conflict_pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_resolve_conflict_pull_requests(mocker: MockerFixture, tmp_path: Path) -
),
mocker.call(["git", "add", "-A"], check=True),
mocker.call(
["git", "commit", "-m", ":beers: publish bot test"], check=True
["git", "commit", "-m", ":beers: publish bot test (#1)"], check=True
),
mocker.call(["git", "push", "origin", "publish/issue1", "-f"], check=True),
]
Expand Down

0 comments on commit 4d0582d

Please sign in to comment.