@@ -72,6 +72,9 @@ def up(self, *args, ok=True) -> str:
7272 self .assertEqual (p .returncode == 0 , ok , f"upstream.py { ' ' .join (args )} -> exit { p .returncode } \n { out } " )
7373 return out
7474
75+ def history (self ) -> list [str ]:
76+ return ["--history" , f"{ self .sha } ..HEAD" , "--clone" , "tinyparse" ]
77+
7578 def state (self ) -> dict :
7679 return json .loads ((self .work / "upstream" / "STATE.json" ).read_text ())
7780
@@ -115,7 +118,7 @@ def walk_to_draft(self, channel=("--channel", "issue")):
115118 self .up ("init" , REPO , * channel , "--user" , "@psjg" )
116119 self .up ("rules" , "--local" , "tinyparse" )
117120 self .up ("rules" , "classify" , "--outcome" , "welcome" , "--form" , "a sentence saying an AI tool helped" )
118- self .up ("search" , "--keywords" , "trailing empty field" )
121+ self .up ("search" , "--keywords" , "trailing empty field" , * self . history () )
119122 self .up ("search" , "mark" , "12" , "related" , "closed; trailing whitespace, a different bug" )
120123 self .up ("search" , "mark" , "7" , "unrelated" , "documentation" )
121124 self .up ("claim" , "add" , "--text" , CLAIM , "--cmd" , CMD , "--permalink" , self .link )
@@ -399,11 +402,33 @@ def test_unmarked_hit_blocks_evidence(self):
399402 self .up ("init" , REPO , "--channel" , "issue" , "--user" , "@psjg" )
400403 self .up ("rules" , "--local" , "tinyparse" )
401404 self .up ("rules" , "classify" , "--outcome" , "welcome" , "--form" , "x" )
402- self .up ("search" , "--keywords" , "trailing" )
405+ self .up ("search" , "--keywords" , "trailing" , * self . history () )
403406 self .up ("search" , "mark" , "12" , "unrelated" , "whitespace" )
404407 self .assertIn ("hit #7 is not marked" , self .up ("status" ))
405408 self .up ("claim" , "add" , "--text" , "t" , "--cmd" , "true" , "--no-permalink" , "none" , ok = False )
406409
410+ def test_history_search_required_and_fix_commits_become_hits (self ):
411+ """A fix merged after the version the user ran is found in the
412+ commits, not in an issue search: its PR number must be marked."""
413+ self .up ("init" , REPO , "--channel" , "issue" , "--user" , "@psjg" )
414+ self .up ("rules" , "--local" , "tinyparse" )
415+ self .up ("rules" , "classify" , "--outcome" , "welcome" , "--form" , "x" )
416+ self .up ("search" , "--keywords" , "trailing" )
417+ self .up ("search" , "mark" , "12" , "unrelated" , "whitespace" )
418+ self .up ("search" , "mark" , "7" , "unrelated" , "docs" )
419+ self .assertIn ("no search of the commits since the reported version" , self .up ("status" ))
420+ self .up ("search" , "--history" , "HEAD" , "--clone" , "tinyparse" , ok = False ) # not a range
421+ clone = self .work / "tinyparse"
422+ with open (clone / "tinyparse" / "__init__.py" , "a" ) as f :
423+ f .write ("# fixed\n " )
424+ subprocess .run (["git" , "-C" , str (clone ), "commit" , "-qam" , "fix: keep a trailing empty field (#31)" ],
425+ env = self .env , check = True )
426+ out = self .up ("search" , "--history" , f"{ self .sha } ..HEAD" , "--clone" , "tinyparse" , "--paths" , "tinyparse" )
427+ self .assertIn ("#31 [COMMITTED] " , out )
428+ self .assertIn ("hit #31 is not marked" , self .up ("status" ))
429+ self .up ("search" , "mark" , "31" , "duplicate" , "fixed on main, unreleased" )
430+ self .assertEqual (self .state ()["state" ], "duplicate" )
431+
407432 def test_unpinned_permalink_refused (self ):
408433 self .walk_to_draft ()
409434 self .up ("claim" , "add" , "--text" , "t" , "--cmd" , "true" , "--permalink" ,
@@ -417,7 +442,7 @@ def test_refuse_outcome_gathers_facts_then_stops(self):
417442 self .up ("rules" , "--local" , "tinyparse" )
418443 self .up ("rules" , "classify" , "--outcome" , "refuse" , "--form" , "a human writes the description" )
419444 self .assertEqual (self .state ()["state" ], "search" )
420- self .up ("search" , "--keywords" , "trailing empty field" )
445+ self .up ("search" , "--keywords" , "trailing empty field" , * self . history () )
421446 self .up ("search" , "mark" , "12" , "unrelated" , "whitespace" )
422447 self .up ("search" , "mark" , "7" , "unrelated" , "docs" )
423448 self .up ("claim" , "add" , "--text" , CLAIM , "--cmd" , CMD , "--permalink" , self .link )
@@ -439,7 +464,7 @@ def test_mailing_list_forbids_html(self):
439464 self .
up (
"init" ,
REPO ,
"--channel" ,
"issue" ,
"--list" ,
"~psjg/[email protected] " ,
"--user" ,
"@psjg" )
440465 self .up ("rules" , "--local" , "tinyparse" )
441466 self .up ("rules" , "classify" , "--outcome" , "welcome" , "--form" , "say so in the report" )
442- self .up ("search" , "--keywords" , "trailing" )
467+ self .up ("search" , "--keywords" , "trailing" , * self . history () )
443468 self .assertIn ("list archive" , self .up ("status" ))
444469 self .up ("search" , "--archive-cmd" , "echo no patches found" )
445470 self .up ("search" , "mark" , "12" , "unrelated" , "whitespace" )
@@ -548,7 +573,7 @@ def setUp(self):
548573 def evidence (self , wd : str ):
549574 self .up ("--workdir" , wd , "rules" , "--local" , "tinyparse" )
550575 self .up ("--workdir" , wd , "rules" , "classify" , "--outcome" , "welcome" , "--form" , "a sentence saying an AI tool helped" )
551- self .up ("--workdir" , wd , "search" , "--keywords" , "trailing empty field" )
576+ self .up ("--workdir" , wd , "search" , "--keywords" , "trailing empty field" , * self . history () )
552577 self .up ("--workdir" , wd , "search" , "mark" , "12" , "unrelated" , "whitespace" )
553578 self .up ("--workdir" , wd , "search" , "mark" , "7" , "unrelated" , "docs" )
554579 self .up ("--workdir" , wd , "claim" , "add" , "--text" , "The patched build passes 621/621." ,
@@ -614,7 +639,7 @@ def test_duplicate_stops(self):
614639 self .up ("init" , REPO , "--channel" , "issue" , "--user" , "@psjg" )
615640 self .up ("rules" , "--local" , "tinyparse" )
616641 self .up ("rules" , "classify" , "--outcome" , "welcome" , "--form" , "x" )
617- out = self .up ("search" , "--keywords" , "trailing empty field" )
642+ out = self .up ("search" , "--keywords" , "trailing empty field" , * self . history () )
618643 self .assertIn ("#12 [CLOSED/NOT_PLANNED]" , out )
619644 self .up ("search" , "mark" , "12" , "duplicate" , "closed as not planned: by design since 0.3" )
620645 self .assertEqual (self .state ()["state" ], "duplicate" )
@@ -629,7 +654,7 @@ def test_handle_without_at(self):
629654 out = self .up ("rules" , "--local" , "tinyparse" )
630655 self .assertIn ("thread:" , out ) # the maintainer's no-mentions request is among the hits
631656 self .up ("rules" , "classify" , "--outcome" , "welcome" , "--form" , "x" , "--no-mentions" )
632- self .up ("search" , "--keywords" , "sep" )
657+ self .up ("search" , "--keywords" , "sep" , * self . history () )
633658 self .up ("search" , "mark" , "12" , "unrelated" , "whitespace" )
634659 self .up ("search" , "mark" , "7" , "related" , "this thread" )
635660 self .up ("claim" , "add" , "--text" , CLAIM , "--cmd" , CMD , "--permalink" , self .link )
0 commit comments