Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ repos:
language: system
types: [python]
args: ["--rcfile=pyproject.toml"]

- id: update-index-date
name: update-index-date
entry: poetry run python scripts/update_index_date.py
language: system
pass_filenames: false
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"url": "https://sayyedasif.com/",
"jobTitle": "Data Scientist"
},
"dateModified": "2026-07-25"
"dateModified": "2026-07-26"
},
{
"@context": "https://schema.org",
Expand All @@ -53,7 +53,7 @@
"name": "Asif Sayyed",
"url": "https://sayyedasif.com/"
},
"dateModified": "2026-07-25"
"dateModified": "2026-07-26"
},
{
"@context": "https://schema.org",
Expand Down Expand Up @@ -143,7 +143,7 @@

<main class="container">
<header class="hero">
<div class="author-badge">Project by Asif Sayyed <span style="opacity: 0.7; margin-left: 10px;">| Last Updated: <time datetime="2026-07-25">July 25, 2026</time></span></div>
<div class="author-badge">Project by Asif Sayyed <span style="opacity: 0.7; margin-left: 10px;">| Last Updated: <time datetime="2026-07-26">July 26, 2026</time></span></div>
<h1 class="title">The Ship of Theseus</h1>
<p class="subtitle">
Track how much of your codebase's original code still
Expand Down
32 changes: 32 additions & 0 deletions scripts/update_index_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import re
import datetime
from pathlib import Path

def update_date():
index_path = Path("index.html")
if not index_path.exists():
return
Comment on lines +6 to +8

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fail loudly when the update did not occur.

A missing index.html or a formatting change that prevents either regex from matching currently exits successfully, allowing stale SEO metadata and visible timestamps to be committed. Resolve the repository path relative to the script/repository and validate re.subn() replacement counts before returning.

Also applies to: 18-25

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/update_index_date.py` around lines 6 - 8, Update the script’s
index-path handling and replacement flow: resolve index.html relative to the
script/repository rather than the current working directory, and make a missing
file fail loudly instead of returning successfully. Capture the replacement
counts from both re.subn calls and validate that each expected regex matched;
raise or otherwise exit with an error when either count is zero, while
preserving successful writes when both replacements occur.


content = index_path.read_text(encoding="utf-8")
original_content = content

now = datetime.datetime.now()
iso_date = now.strftime("%Y-%m-%d")
human_date = now.strftime("%B %d, %Y").replace(" 0", " ") # Format like 'July 26, 2026'
Comment on lines +13 to +15

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Repository files matching update_index_date.py:\n'
fd -a 'update_index_date.py' . || true

printf '\nRelevant file contents:\n'
if [ -f scripts/update_index_date.py ]; then
  cat -n scripts/update_index_date.py
fi

printf '\nSearch for update script date usages/requirements:\n'
rg -n "update_index_date|last\\s+updated|generated|datetime\\.now|timezone|tzinfo" -S . || true

Repository: Asifdotexe/Theseus

Length of output: 50375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Candidate files:\n'
fd -e py -e html 'update_index_date|index\.html' . || true

printf '\nDirect file contents:\n'
if [ -f scripts/update_index_date.py ]; then
  cat -n scripts/update_index_date.py
fi

printf '\nDirect focused searches:\n'
rg -n --max-count 200 "update_index_date|last\\s+updated|updated on|datetime\\.now\\(|datetime\\.(utcfromtimestamp|utcnow)|timezone|tzinfo|strftime\\(\"%Y-%m-%d%b|%B %d" . || true

Repository: Asifdotexe/Theseus

Length of output: 2745


Use UTC when updating the index date.

datetime.datetime.now() depends on the contributor’s local timezone, so the same commit run near midnight can update index.html to different dates in different timezones. Use datetime.now(datetime.UTC) or another explicit canonical timezone.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/update_index_date.py` around lines 13 - 15, Update the date
initialization in the index-date update flow to use the UTC timezone explicitly
instead of the local-timezone-dependent datetime.datetime.now(). Keep the
existing iso_date and human_date formatting unchanged.


# Update dateModified in JSON-LD
content = re.sub(r'"dateModified": "\d{4}-\d{2}-\d{2}"', f'"dateModified": "{iso_date}"', content)

# Update time tag
content = re.sub(
r'<time datetime="\d{4}-\d{2}-\d{2}">[^<]+</time>',
f'<time datetime="{iso_date}">{human_date}</time>',
content
)

if content != original_content:
index_path.write_text(content, encoding="utf-8")
print(f"Updated index.html date to {iso_date}")

if __name__ == "__main__":
update_date()
Loading