feat: Use Git to get the last modified date

This commit is contained in:
Paul Gauthier (aider) 2024-08-09 11:04:48 -03:00
parent f6c9f86ea4
commit f2c7ba3f36

View file

@ -291,7 +291,7 @@ Submit results by opening a PR with edits to the
By Paul Gauthier, By Paul Gauthier,
last updated last updated
<!--[[[cog <!--[[[cog
import os import subprocess
import datetime import datetime
files = [ files = [
@ -300,10 +300,16 @@ files = [
'aider/website/_data/refactor_leaderboard.yml' 'aider/website/_data/refactor_leaderboard.yml'
] ]
mod_times = [os.path.getmtime(file) for file in files] def get_last_modified_date(file):
latest_mod_time = max(mod_times) result = subprocess.run(['git', 'log', '-1', '--format=%ct', file], capture_output=True, text=True)
mod_date = datetime.datetime.fromtimestamp(latest_mod_time) if result.returncode == 0:
cog.out(f"{mod_date.strftime('%B %d, %Y.')}") timestamp = int(result.stdout.strip())
return datetime.datetime.fromtimestamp(timestamp)
return datetime.datetime.min
mod_dates = [get_last_modified_date(file) for file in files]
latest_mod_date = max(mod_dates)
cog.out(f"{latest_mod_date.strftime('%B %d, %Y.')}")
]]]--> ]]]-->
August 09, 2024. August 09, 2024.
<!--[[[end]]]--> <!--[[[end]]]-->