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,
last updated
<!--[[[cog
import os
import subprocess
import datetime
files = [
@ -300,10 +300,16 @@ files = [
'aider/website/_data/refactor_leaderboard.yml'
]
mod_times = [os.path.getmtime(file) for file in files]
latest_mod_time = max(mod_times)
mod_date = datetime.datetime.fromtimestamp(latest_mod_time)
cog.out(f"{mod_date.strftime('%B %d, %Y.')}")
def get_last_modified_date(file):
result = subprocess.run(['git', 'log', '-1', '--format=%ct', file], capture_output=True, text=True)
if result.returncode == 0:
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.
<!--[[[end]]]-->