Pick each replay's commits by the newest author time, in place of the first such commit in log order
CI / tests (pull_request) Successful in 2m13s
CI / tests (pull_request) Successful in 2m13s
This commit is contained in:
@@ -93,8 +93,8 @@ def lost_inputs(prompt: str, reports: str, held: typing.Callable[[str], bool]) -
|
||||
|
||||
|
||||
def authored_by(log: list[tuple[str, float]], seconds: float) -> str | None:
|
||||
"""The newest commit in log, which lists newest first, authored at or before seconds. A rebase keeps author times, so a merged branch's commits still say what it held."""
|
||||
return next((commit for commit, authored in log if authored <= seconds), None)
|
||||
"""The commit in log with the newest author time at or before seconds; the first in log order breaks a tie. A rebase keeps author times, so a merged branch's commits still say what it held. Log order alone would not do: a commit authored early but merged late, such as a dependency bump, sits high in it."""
|
||||
return max(((commit, authored) for commit, authored in log if authored <= seconds), key=lambda listed: listed[1], default=(None, 0))[0]
|
||||
|
||||
|
||||
def sample(rounds: list[Round], latest: int) -> list[Round]:
|
||||
|
||||
@@ -99,6 +99,14 @@ class AuthoredBy(unittest.TestCase):
|
||||
self.assertEqual(authored_by(log, 30), "c3")
|
||||
self.assertIsNone(authored_by(log, 5))
|
||||
|
||||
def test_takes_the_newest_author_time_over_a_commit_authored_early_but_merged_late(self):
|
||||
log = [("bump", 5), ("c3", 30), ("c2", 20)]
|
||||
self.assertEqual(authored_by(log, 25), "c2")
|
||||
self.assertEqual(authored_by(log, 10), "bump")
|
||||
|
||||
def test_breaks_a_tie_by_log_order(self):
|
||||
self.assertEqual(authored_by([("merged", 20), ("earlier", 20)], 25), "merged")
|
||||
|
||||
|
||||
class Sample(unittest.TestCase):
|
||||
def test_keeps_the_latest_rounds_in_the_order_they_ran(self):
|
||||
|
||||
Reference in New Issue
Block a user