fix: recount commits touching a path once stale

The commit list behind the triage drift score was cached for good,
so pushes upstream never moved a profile up the triage. It now
expires like the other moving answers.
This commit is contained in:
Abdessamad Derraz committed 2026-10-18 03:53:12 +02:00
1 parent 2dcb49fa4c
commit 2a13e3ee11
2 files changed
+27 -1

No files matched your search

+3 -1
View File
@@ -773,7 +773,9 @@ def commits_touching(
f"{repo.api_base}/repos/{repo.slug}/commits"
f"?path={quoted}&since={stamp}&limit=100"
)
payload = _api(url, cache_dir, offline)
# The list grows with every push touching the path: cached for good, the
# triage drift score stayed at whatever the first run counted.
payload = _api(url, cache_dir, offline, MOVING_TTL)
if not isinstance(payload, list):
return 0
return sum(
+24
View File
@@ -648,6 +648,30 @@ class TestCompare(unittest.TestCase):
upstream.commits_touching(self.repo, "a.c", "tip", self.dir, head="tip"), 0
)
def test_commits_touching_is_recounted_once_stale(self):
"""The list grows with every push: cached for good, the triage drift
score stayed at what the first run counted."""
import os as _os
served = {
"commits/base": {"commit": {"committer": {"date": "2026-01-01T00:00:00Z"}}},
}
listing = [{"sha": "1"}]
def answer(url):
for key, value in served.items():
if url.endswith(key):
return value
return list(listing)
upstream._http_json = answer
self.assertEqual(upstream.commits_touching(self.repo, "a.c", "base", self.dir), 1)
for cached in (Path(self.dir) / "_api").glob("*.json"):
stale = _os.path.getmtime(cached) - upstream.MOVING_TTL - 1
_os.utime(cached, (stale, stale))
listing.extend([{"sha": "2"}, {"sha": "3"}])
self.assertEqual(upstream.commits_touching(self.repo, "a.c", "base", self.dir), 3)
class TestGitlabTree(unittest.TestCase):
def setUp(self):