@@ -20,11 +20,13 @@ def branches_from_devguide(devguide_dir: Path) -> list[str]:
2020 ]
2121
2222
23- def get_completion (clones_dir : str , repo : str ) -> tuple [float , 'TranslatorsData' , str ]:
23+ def get_completion (
24+ clones_dir : str , repo : str
25+ ) -> tuple [float , 'TranslatorsData' , str , float ]:
2426 clone_path = Path (clones_dir , repo )
2527 for branch in branches_from_devguide (Path (clones_dir , 'devguide' )) + ['master' ]:
2628 try :
27- git .Repo .clone_from (
29+ clone_repo = git .Repo .clone_from (
2830 f'https://github.com/{ repo } .git' , clone_path , branch = branch
2931 )
3032 except git .GitCommandError :
@@ -44,7 +46,27 @@ def get_completion(clones_dir: str, repo: str) -> tuple[float, 'TranslatorsData'
4446 hide_reserved = False ,
4547 api_url = '' ,
4648 ).completion
47- return completion , translators_data , branch
49+
50+ if completion :
51+ # Fetch commit from before 30 days ago and checkout
52+ commit = next (
53+ clone_repo .iter_commits ('HEAD' , max_count = 1 , before = '30 days ago' )
54+ )
55+ clone_repo .git .checkout (commit .hexsha )
56+ with TemporaryDirectory () as tmpdir :
57+ month_ago_completion = potodo .merge_and_scan_path (
58+ clone_path ,
59+ pot_path = Path (clones_dir , 'cpython/Doc/build/gettext' ),
60+ merge_path = Path (tmpdir ),
61+ hide_reserved = False ,
62+ api_url = '' ,
63+ ).completion
64+ else :
65+ month_ago_completion = 0.0
66+
67+ change = completion - month_ago_completion
68+
69+ return completion , translators_data , branch , change
4870
4971
5072@dataclass (frozen = True )
0 commit comments