diff options
| author | user@node5.net <user@node5.net> | 2026-04-14 22:17:33 +0200 |
|---|---|---|
| committer | user@node5.net <user@node5.net> | 2026-04-14 22:17:33 +0200 |
| commit | 7fe279ada3c9a23d78e882b76bd95ef774b43a8e (patch) | |
| tree | ff46b0e7ce56db3abb98e6c32578c7bb26a45886 /get-commit-dates.py | |
| parent | 029671f77da344a1326e413e93939574eae4f891 (diff) | |
| parent | 9b01d51a610a26141ef0f21d1b61c681d46d2426 (diff) | |
merge upstream main 2026-04-14 onto map libremaplibre
some functionalities still broken
Diffstat (limited to 'get-commit-dates.py')
| -rw-r--r-- | get-commit-dates.py | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/get-commit-dates.py b/get-commit-dates.py new file mode 100644 index 0000000..53485d5 --- /dev/null +++ b/get-commit-dates.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 +import json +import subprocess + +INPUT_FILE = "static/js/data.json" +OUTPUT_FILE = "data_with_dates.json" + +def get_git_info(filepath): + try: + cmd = [ + "git", "log", + "--diff-filter=A", + "--follow", + "--reverse", + "--format=%ad|%an", + "--date=format:%Y-%m-%d", + "--", filepath + ] + + output = subprocess.check_output(cmd, text=True).strip() + if not output: + return None, None + + first_line = output.splitlines()[0] + date, author = first_line.split("|", 1) + return date, author + + except subprocess.CalledProcessError: + return None, None + + +with open(INPUT_FILE, "r", encoding="utf-8") as f: + data = json.load(f) + + +cache = {} + +for key, entry in data.items(): + image = entry.get("image") + if not image: + continue + + if image not in cache: + cache[image] = get_git_info(image) + + date, author = cache[image] + + if date: + entry["date"] = date +# if author: +# entry["committer"] = author + + +with open(OUTPUT_FILE, "w", encoding="utf-8") as f: + json.dump(data, f, indent=2, ensure_ascii=False) + + +#import subprocess +#import json +#from pathlib import Path +# +#repo_path = Path(".") +#images_path = repo_path / "static/images" +# +#result = {} +# +#for image in images_path.glob("*"): +# try: +# cmd = [ +# "git", "log", +# "--diff-filter=A", +# "--follow", +# "--reverse", +# "--format=%ad|%an", +# "--date=format:%Y-%m-%d", +# "--", str(image) +# ] +# +# output = subprocess.check_output(cmd, text=True).strip() +# if not output: +# continue +# +# first_line = output.splitlines()[0] +# date, author = first_line.split("|", 1) +# +# result[str(image)] = { +# "date": date, +# "committer": author +# } +# +# except subprocess.CalledProcessError: +# continue +# +#print(json.dumps(result, indent=2)) +# |
