@@ -697,6 +697,74 @@ def test_full_land_approves_with_empty_body(make_config, tmp_path):
697697 assert pr .created_reviews == [("APPROVE" , "" )]
698698
699699
700+ def test_full_land_skips_reapproval_when_already_approved (make_config , tmp_path , caplog ):
701+ rec = _Recorder ()
702+ emit = _FakeEmit (rec )
703+ reviews = [_FakeReview (1 , _BOT , "APPROVED" , rec )]
704+ pr = _FakePR ("h" , rec , reviews = reviews )
705+ gh = _FakeGithub (_FakeRepo (pr ))
706+ vf = _write_verdict (tmp_path , status = "LAND" , reason = "clean" , message = "LGTM" )
707+ req = VerdictRequest (repo = "r" , pr_number = 40 , head_sha = "h" , eval_hash = _HASH , verdict_file = vf , bot_login = _BOT )
708+
709+ with caplog .at_level (logging .INFO , logger = "greenlight" ):
710+ verdict .run (req , make_config (github_token = "tok" ), build_github = lambda t : gh , emit = emit , now = lambda : _FIXED )
711+
712+ # A live greenlight approval already exists: no second APPROVE review is posted (the prior one is
713+ # left intact), yet the canonical comment is still upserted and the skip is logged.
714+ assert pr .created_reviews == []
715+ assert reviews [0 ].dismissed_with is None
716+ assert rec .events == ["emit" , "comment" ]
717+ assert pr .comments [0 ].startswith (comment_format .COMMENT_MARKER )
718+ assert f"**{ comment_format .LAND_HEADLINE } **" in pr .comments [0 ]
719+ assert "LGTM" in pr .comments [0 ]
720+ assert any ("skipping re-approval" in record .getMessage () for record in caplog .records )
721+
722+
723+ def test_full_land_reapproves_when_prior_bot_approval_dismissed (make_config , tmp_path ):
724+ rec = _Recorder ()
725+ emit = _FakeEmit (rec )
726+ pr = _FakePR ("h" , rec , reviews = [_FakeReview (1 , _BOT , "DISMISSED" , rec )])
727+ gh = _FakeGithub (_FakeRepo (pr ))
728+ vf = _write_verdict (tmp_path , status = "LAND" , reason = "clean" , message = "LGTM" )
729+ req = VerdictRequest (repo = "r" , pr_number = 41 , head_sha = "h" , eval_hash = _HASH , verdict_file = vf , bot_login = _BOT )
730+
731+ verdict .run (req , make_config (github_token = "tok" ), build_github = lambda t : gh , emit = emit , now = lambda : _FIXED )
732+
733+ # A prior greenlight approval that was dismissed is not live, so LAND re-approves.
734+ assert pr .created_reviews == [("APPROVE" , "" )]
735+ assert rec .events == ["emit" , "review:APPROVE" , "comment" ]
736+
737+
738+ def test_full_land_approves_when_only_other_author_approved (make_config , tmp_path ):
739+ rec = _Recorder ()
740+ emit = _FakeEmit (rec )
741+ pr = _FakePR ("h" , rec , reviews = [_FakeReview (1 , "alice" , "APPROVED" , rec )])
742+ gh = _FakeGithub (_FakeRepo (pr ))
743+ vf = _write_verdict (tmp_path , status = "LAND" , reason = "clean" , message = "LGTM" )
744+ req = VerdictRequest (repo = "r" , pr_number = 42 , head_sha = "h" , eval_hash = _HASH , verdict_file = vf , bot_login = _BOT )
745+
746+ verdict .run (req , make_config (github_token = "tok" ), build_github = lambda t : gh , emit = emit , now = lambda : _FIXED )
747+
748+ # A human's approval is not greenlight's own, so LAND still posts greenlight's approval.
749+ assert pr .created_reviews == [("APPROVE" , "" )]
750+ assert rec .events == ["emit" , "review:APPROVE" , "comment" ]
751+
752+
753+ def test_full_land_approves_when_only_bot_commented_review (make_config , tmp_path ):
754+ rec = _Recorder ()
755+ emit = _FakeEmit (rec )
756+ pr = _FakePR ("h" , rec , reviews = [_FakeReview (1 , _BOT , "COMMENTED" , rec )])
757+ gh = _FakeGithub (_FakeRepo (pr ))
758+ vf = _write_verdict (tmp_path , status = "LAND" , reason = "clean" , message = "LGTM" )
759+ req = VerdictRequest (repo = "r" , pr_number = 43 , head_sha = "h" , eval_hash = _HASH , verdict_file = vf , bot_login = _BOT )
760+
761+ verdict .run (req , make_config (github_token = "tok" ), build_github = lambda t : gh , emit = emit , now = lambda : _FIXED )
762+
763+ # A COMMENTED review from greenlight is not an approval, so LAND posts one.
764+ assert pr .created_reviews == [("APPROVE" , "" )]
765+ assert rec .events == ["emit" , "review:APPROVE" , "comment" ]
766+
767+
700768class _CommentBoomPR (_FakePR ):
701769 """A PR whose issue-comment create always fails, to prove the cosmetic write is best-effort."""
702770
0 commit comments