claude-dev-env 8.48.3 → 8.48.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -607,6 +607,7 @@ def read_pull_request(slug: str, number: int, token: str) -> Mapping[str, object
|
|
|
607
607
|
def read_blocked_evidence(
|
|
608
608
|
slug: str,
|
|
609
609
|
all_pull_request_fields: Mapping[str, object],
|
|
610
|
+
all_rules: list[object] | MergeCheckError,
|
|
610
611
|
token: str,
|
|
611
612
|
) -> BlockedEvidence:
|
|
612
613
|
"""Read what stands behind a ``blocked`` merge state.
|
|
@@ -615,6 +616,8 @@ def read_blocked_evidence(
|
|
|
615
616
|
slug: The repository as ``owner/name``.
|
|
616
617
|
all_pull_request_fields: The pull request, carrying its base branch
|
|
617
618
|
and its head commit.
|
|
619
|
+
all_rules: The base branch rules, or the failure that kept them
|
|
620
|
+
unread.
|
|
618
621
|
token: The GitHub token the requests authenticate with.
|
|
619
622
|
|
|
620
623
|
Returns:
|
|
@@ -628,7 +631,8 @@ def read_blocked_evidence(
|
|
|
628
631
|
str(_nested_field(all_pull_request_fields, BASE_KEY, REF_KEY))
|
|
629
632
|
)
|
|
630
633
|
head_sha = str(_nested_field(all_pull_request_fields, HEAD_KEY, SHA_KEY))
|
|
631
|
-
|
|
634
|
+
if isinstance(all_rules, MergeCheckError):
|
|
635
|
+
raise all_rules
|
|
632
636
|
return BlockedEvidence(
|
|
633
637
|
all_unmet_checks=_read_unmet_checks(slug, head_sha, all_rules, token),
|
|
634
638
|
behind_by=_read_behind_by(slug, base_ref, head_sha, token),
|
|
@@ -636,13 +640,30 @@ def read_blocked_evidence(
|
|
|
636
640
|
)
|
|
637
641
|
|
|
638
642
|
|
|
639
|
-
def
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
643
|
+
def read_branch_rules(
|
|
644
|
+
slug: str, base_ref: str, token: str
|
|
645
|
+
) -> list[object] | MergeCheckError:
|
|
646
|
+
"""Read the rules GitHub reports as active on the base branch.
|
|
647
|
+
|
|
648
|
+
Args:
|
|
649
|
+
slug: The repository as ``owner/name``.
|
|
650
|
+
base_ref: The branch the pull request merges into.
|
|
651
|
+
token: The GitHub token the request authenticates with.
|
|
652
|
+
|
|
653
|
+
Returns:
|
|
654
|
+
The rules, or the failure that kept them unread.
|
|
655
|
+
"""
|
|
656
|
+
try:
|
|
657
|
+
return _request_list(
|
|
658
|
+
BRANCH_RULES_ENDPOINT_TEMPLATE.format(
|
|
659
|
+
api_root=GITHUB_API_ROOT,
|
|
660
|
+
slug=slug,
|
|
661
|
+
branch=urllib.parse.quote(base_ref),
|
|
662
|
+
),
|
|
663
|
+
token,
|
|
664
|
+
)
|
|
665
|
+
except MergeCheckError as failure:
|
|
666
|
+
return failure
|
|
646
667
|
|
|
647
668
|
|
|
648
669
|
def read_unstable_checks(
|
|
@@ -879,7 +900,11 @@ def _field_at(document: object, all_fields: object, key: str) -> object:
|
|
|
879
900
|
|
|
880
901
|
|
|
881
902
|
def read_merge_queue_ejection(
|
|
882
|
-
slug: str,
|
|
903
|
+
slug: str,
|
|
904
|
+
number: int,
|
|
905
|
+
base_ref: str,
|
|
906
|
+
all_rules: list[object] | MergeCheckError,
|
|
907
|
+
token: str,
|
|
883
908
|
) -> bool:
|
|
884
909
|
"""Read whether the merge queue ejected the pull request's current head.
|
|
885
910
|
|
|
@@ -891,6 +916,8 @@ def read_merge_queue_ejection(
|
|
|
891
916
|
slug: The repository as ``owner/name``.
|
|
892
917
|
number: The pull request number.
|
|
893
918
|
base_ref: The branch the pull request merges into.
|
|
919
|
+
all_rules: The base branch rules, or the failure that kept them
|
|
920
|
+
unread.
|
|
894
921
|
token: The GitHub token the request authenticates with.
|
|
895
922
|
|
|
896
923
|
Returns:
|
|
@@ -901,7 +928,9 @@ def read_merge_queue_ejection(
|
|
|
901
928
|
MergeCheckError: A read failed, or answered with another shape. A
|
|
902
929
|
refused GraphQL query names the merge queue that needed it.
|
|
903
930
|
"""
|
|
904
|
-
if not
|
|
931
|
+
if not isinstance(all_rules, MergeCheckError) and not has_merge_queue_rule(
|
|
932
|
+
all_rules
|
|
933
|
+
):
|
|
905
934
|
return False
|
|
906
935
|
document = _merge_queue_removal_document(slug, number, base_ref, token)
|
|
907
936
|
return _is_ejected_on_head(
|
|
@@ -924,14 +953,6 @@ def _merge_queue_removal_document(
|
|
|
924
953
|
) from failure
|
|
925
954
|
|
|
926
955
|
|
|
927
|
-
def _may_merge_through_a_queue(slug: str, base_ref: str, token: str) -> bool:
|
|
928
|
-
try:
|
|
929
|
-
all_rules = _read_branch_rules(slug, urllib.parse.quote(base_ref), token)
|
|
930
|
-
except MergeCheckError:
|
|
931
|
-
return True
|
|
932
|
-
return has_merge_queue_rule(all_rules)
|
|
933
|
-
|
|
934
|
-
|
|
935
956
|
def _list_along(document: object, all_keys: Sequence[str]) -> list[object]:
|
|
936
957
|
all_records = functools.reduce(
|
|
937
958
|
functools.partial(_field_at, document), all_keys, document
|
|
@@ -1009,11 +1030,10 @@ def main(all_arguments: Sequence[str]) -> int:
|
|
|
1009
1030
|
unresolved_thread_count = read_unresolved_thread_count(
|
|
1010
1031
|
parsed.slug, parsed.number, token
|
|
1011
1032
|
)
|
|
1033
|
+
base_ref = str(_nested_field(all_pull_request_fields, BASE_KEY, REF_KEY))
|
|
1034
|
+
all_rules = read_branch_rules(parsed.slug, base_ref, token)
|
|
1012
1035
|
is_ejected_from_merge_queue = read_merge_queue_ejection(
|
|
1013
|
-
parsed.slug,
|
|
1014
|
-
parsed.number,
|
|
1015
|
-
str(_nested_field(all_pull_request_fields, BASE_KEY, REF_KEY)),
|
|
1016
|
-
token,
|
|
1036
|
+
parsed.slug, parsed.number, base_ref, all_rules, token
|
|
1017
1037
|
)
|
|
1018
1038
|
except MergeCheckError as failure:
|
|
1019
1039
|
print(failure, file=sys.stderr)
|
|
@@ -1022,7 +1042,7 @@ def main(all_arguments: Sequence[str]) -> int:
|
|
|
1022
1042
|
if all_pull_request_fields.get(MERGEABLE_STATE_KEY) == MERGEABLE_STATE_BLOCKED:
|
|
1023
1043
|
try:
|
|
1024
1044
|
blocked_evidence = read_blocked_evidence(
|
|
1025
|
-
parsed.slug, all_pull_request_fields, token
|
|
1045
|
+
parsed.slug, all_pull_request_fields, all_rules, token
|
|
1026
1046
|
)
|
|
1027
1047
|
except MergeCheckError as failure:
|
|
1028
1048
|
print(failure, file=sys.stderr)
|
|
@@ -291,10 +291,15 @@ def test_a_ready_pull_request_exits_zero(monkeypatch: pytest.MonkeyPatch) -> Non
|
|
|
291
291
|
"read_unresolved_thread_count",
|
|
292
292
|
lambda slug, number, token: 0,
|
|
293
293
|
)
|
|
294
|
+
monkeypatch.setattr(
|
|
295
|
+
agent_merge_check,
|
|
296
|
+
"read_branch_rules",
|
|
297
|
+
lambda slug, base_ref, token: [],
|
|
298
|
+
)
|
|
294
299
|
monkeypatch.setattr(
|
|
295
300
|
agent_merge_check,
|
|
296
301
|
"read_merge_queue_ejection",
|
|
297
|
-
lambda slug, number, base_ref, token: False,
|
|
302
|
+
lambda slug, number, base_ref, all_rules, token: False,
|
|
298
303
|
)
|
|
299
304
|
assert agent_merge_check.main(["jl-cmd/claude-dev-env", "1442"]) == 0
|
|
300
305
|
|
|
@@ -311,10 +316,15 @@ def test_a_held_pull_request_exits_one(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
|
311
316
|
"read_unresolved_thread_count",
|
|
312
317
|
lambda slug, number, token: 0,
|
|
313
318
|
)
|
|
319
|
+
monkeypatch.setattr(
|
|
320
|
+
agent_merge_check,
|
|
321
|
+
"read_branch_rules",
|
|
322
|
+
lambda slug, base_ref, token: [],
|
|
323
|
+
)
|
|
314
324
|
monkeypatch.setattr(
|
|
315
325
|
agent_merge_check,
|
|
316
326
|
"read_merge_queue_ejection",
|
|
317
|
-
lambda slug, number, base_ref, token: False,
|
|
327
|
+
lambda slug, number, base_ref, all_rules, token: False,
|
|
318
328
|
)
|
|
319
329
|
assert agent_merge_check.main(["jl-cmd/claude-dev-env", "1442"]) == 1
|
|
320
330
|
|
|
@@ -491,6 +501,65 @@ def test_an_unreadable_branch_rule_keeps_the_generic_blocked_reason(
|
|
|
491
501
|
assert BLOCKED_HOLD_REASON in line
|
|
492
502
|
|
|
493
503
|
|
|
504
|
+
def test_a_blocked_pull_request_reads_the_branch_rules_once(
|
|
505
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
506
|
+
capsys: pytest.CaptureFixture[str],
|
|
507
|
+
) -> None:
|
|
508
|
+
routed_answer = _github_answers(
|
|
509
|
+
MAIN_BRANCH_RULES,
|
|
510
|
+
[
|
|
511
|
+
_check_run("Ruff", "success", run_id=11),
|
|
512
|
+
_check_run("Tip Local green", "success", run_id=12),
|
|
513
|
+
],
|
|
514
|
+
behind_by=225,
|
|
515
|
+
)
|
|
516
|
+
all_rules_urls: list[str] = []
|
|
517
|
+
|
|
518
|
+
def _answer(url: str, token: str, all_payload_fields: object) -> object:
|
|
519
|
+
if "/rules/branches/" in url:
|
|
520
|
+
all_rules_urls.append(url)
|
|
521
|
+
return routed_answer(url, token, all_payload_fields)
|
|
522
|
+
|
|
523
|
+
exit_code, line = _run_main(monkeypatch, capsys, _answer)
|
|
524
|
+
assert exit_code == 1
|
|
525
|
+
assert BEHIND_MERGE_QUEUE_HOLD_TEMPLATE.format(count=225) in line
|
|
526
|
+
assert len(all_rules_urls) == 1
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def test_read_branch_rules_quotes_the_base_branch_and_returns_its_rules(
|
|
530
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
531
|
+
) -> None:
|
|
532
|
+
all_rules_urls: list[str] = []
|
|
533
|
+
|
|
534
|
+
def _answer(url: str, token: str, all_payload_fields: object) -> object:
|
|
535
|
+
all_rules_urls.append(url)
|
|
536
|
+
return MAIN_BRANCH_RULES
|
|
537
|
+
|
|
538
|
+
monkeypatch.setattr(agent_merge_check, "_request_json", _answer)
|
|
539
|
+
assert (
|
|
540
|
+
agent_merge_check.read_branch_rules(
|
|
541
|
+
"jl-cmd/claude-dev-env", "release/2026 q4", "token"
|
|
542
|
+
)
|
|
543
|
+
== MAIN_BRANCH_RULES
|
|
544
|
+
)
|
|
545
|
+
assert all_rules_urls[0].endswith("/rules/branches/release/2026%20q4")
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
def test_read_branch_rules_returns_the_failure_of_a_refused_read(
|
|
549
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
550
|
+
) -> None:
|
|
551
|
+
refusal = agent_merge_check.MergeCheckError("HTTP Error 403: Forbidden")
|
|
552
|
+
|
|
553
|
+
def _refuse(url: str, token: str, all_payload_fields: object) -> object:
|
|
554
|
+
raise refusal
|
|
555
|
+
|
|
556
|
+
monkeypatch.setattr(agent_merge_check, "_request_json", _refuse)
|
|
557
|
+
assert (
|
|
558
|
+
agent_merge_check.read_branch_rules("jl-cmd/claude-dev-env", "main", "token")
|
|
559
|
+
is refusal
|
|
560
|
+
)
|
|
561
|
+
|
|
562
|
+
|
|
494
563
|
def _evidence(
|
|
495
564
|
all_unmet_checks: tuple[str, ...] = (),
|
|
496
565
|
behind_by: int = 0,
|
|
@@ -626,7 +695,7 @@ def test_read_blocked_evidence_reads_the_pull_request_4922_shape(
|
|
|
626
695
|
),
|
|
627
696
|
)
|
|
628
697
|
assert agent_merge_check.read_blocked_evidence(
|
|
629
|
-
"jl-cmd/claude-dev-env", PULL_REQUEST_4922, "token"
|
|
698
|
+
"jl-cmd/claude-dev-env", PULL_REQUEST_4922, MAIN_BRANCH_RULES, "token"
|
|
630
699
|
) == _evidence(behind_by=225)
|
|
631
700
|
|
|
632
701
|
|
|
@@ -821,7 +890,7 @@ def test_read_merge_queue_ejection_compares_failed_checks_removals_to_the_head(
|
|
|
821
890
|
)
|
|
822
891
|
assert (
|
|
823
892
|
agent_merge_check.read_merge_queue_ejection(
|
|
824
|
-
"jl-cmd/claude-dev-env", 1442, "main", "token"
|
|
893
|
+
"jl-cmd/claude-dev-env", 1442, "main", MAIN_BRANCH_RULES, "token"
|
|
825
894
|
)
|
|
826
895
|
is expected_ejection
|
|
827
896
|
)
|