Skip to content

Commit

Permalink
fix: 获取数据前先切换到拉取请求对应的分支
Browse files Browse the repository at this point in the history
  • Loading branch information
he0119 committed Aug 23, 2023
1 parent 4ce79d8 commit 35a7328
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/plugins/publish/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ async def resolve_conflict_pull_requests(

publish_type = get_type_by_labels(pull.labels)
if publish_type:
# 因为当前分支为触发处理冲突的分支,所以需要切换到每个拉取请求对应的分支
run_shell_command(["git", "checkout", pull.head.ref])
# 获取数据
result = generate_validation_dict_from_file(publish_type)
# 回到主分支
run_shell_command(["git", "checkout", plugin_config.input_config.base])
Expand Down
9 changes: 9 additions & 0 deletions tests/publish/utils/test_resolve_conflict_pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ async def test_resolve_conflict_pull_requests_adapter(
# 测试 git 命令
mock_subprocess_run.assert_has_calls(
[
mocker.call(
["git", "checkout", "publish/issue1"], check=True, capture_output=True
),
mocker.call(["git", "checkout", "master"], check=True, capture_output=True),
mocker.call(
["git", "switch", "-C", "publish/issue1"],
Expand Down Expand Up @@ -185,6 +188,9 @@ async def test_resolve_conflict_pull_requests_bot(
# 测试 git 命令
mock_subprocess_run.assert_has_calls(
[
mocker.call(
["git", "checkout", "publish/issue1"], check=True, capture_output=True
),
mocker.call(["git", "checkout", "master"], check=True, capture_output=True),
mocker.call(
["git", "switch", "-C", "publish/issue1"],
Expand Down Expand Up @@ -305,6 +311,9 @@ async def test_resolve_conflict_pull_requests_plugin(
# 测试 git 命令
mock_subprocess_run.assert_has_calls(
[
mocker.call(
["git", "checkout", "publish/issue1"], check=True, capture_output=True
),
mocker.call(["git", "checkout", "master"], check=True, capture_output=True),
mocker.call(
["git", "switch", "-C", "publish/issue1"],
Expand Down

0 comments on commit 35a7328

Please sign in to comment.