Skip to content

Commit 35a7328

Browse files
committed
fix: 获取数据前先切换到拉取请求对应的分支
1 parent 4ce79d8 commit 35a7328

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/plugins/publish/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ async def resolve_conflict_pull_requests(
275275

276276
publish_type = get_type_by_labels(pull.labels)
277277
if publish_type:
278+
# 因为当前分支为触发处理冲突的分支,所以需要切换到每个拉取请求对应的分支
279+
run_shell_command(["git", "checkout", pull.head.ref])
280+
# 获取数据
278281
result = generate_validation_dict_from_file(publish_type)
279282
# 回到主分支
280283
run_shell_command(["git", "checkout", plugin_config.input_config.base])

tests/publish/utils/test_resolve_conflict_pull_requests.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ async def test_resolve_conflict_pull_requests_adapter(
6565
# 测试 git 命令
6666
mock_subprocess_run.assert_has_calls(
6767
[
68+
mocker.call(
69+
["git", "checkout", "publish/issue1"], check=True, capture_output=True
70+
),
6871
mocker.call(["git", "checkout", "master"], check=True, capture_output=True),
6972
mocker.call(
7073
["git", "switch", "-C", "publish/issue1"],
@@ -185,6 +188,9 @@ async def test_resolve_conflict_pull_requests_bot(
185188
# 测试 git 命令
186189
mock_subprocess_run.assert_has_calls(
187190
[
191+
mocker.call(
192+
["git", "checkout", "publish/issue1"], check=True, capture_output=True
193+
),
188194
mocker.call(["git", "checkout", "master"], check=True, capture_output=True),
189195
mocker.call(
190196
["git", "switch", "-C", "publish/issue1"],
@@ -305,6 +311,9 @@ async def test_resolve_conflict_pull_requests_plugin(
305311
# 测试 git 命令
306312
mock_subprocess_run.assert_has_calls(
307313
[
314+
mocker.call(
315+
["git", "checkout", "publish/issue1"], check=True, capture_output=True
316+
),
308317
mocker.call(["git", "checkout", "master"], check=True, capture_output=True),
309318
mocker.call(
310319
["git", "switch", "-C", "publish/issue1"],

0 commit comments

Comments
 (0)