From 04f5c56c8575ac15e831efe0f0b1e9bc4eb70cf9 Mon Sep 17 00:00:00 2001 From: Aayushman-nvm Date: Mon, 23 Feb 2026 17:53:38 +0000 Subject: [PATCH 1/3] fix: fetch full history for submodules to fix incorrect last-modified dates --- .github/workflows/deploy.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 782402d56cb..54374c1472d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,6 +35,12 @@ jobs: path: website fetch-depth: 0 # full history required to determine last edit + - name: Fetch full history for submodules + working-directory: website + run: | + git submodule foreach --recursive "git fetch --unshallow 2>/dev/null || true" + git submodule foreach --recursive "git fetch --all" + - name: Fetch - precice develop uses: actions/checkout@v4 with: From 0d93065ea5045b157e0aafbd2fd9dfb0b56f9b06 Mon Sep 17 00:00:00 2001 From: Aayushman-nvm Date: Tue, 24 Feb 2026 05:27:27 +0000 Subject: [PATCH 2/3] fix: fetch full history for submodules to fix incorrect last-modified dates --- .github/workflows/deploy.yml | 10 +++++++ inject_dates.sh | 57 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 inject_dates.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 54374c1472d..c2fb9b56590 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -41,6 +41,10 @@ jobs: git submodule foreach --recursive "git fetch --unshallow 2>/dev/null || true" git submodule foreach --recursive "git fetch --all" + - name: Inject last_modified_at dates from submodules + working-directory: website + run: bash inject_dates.sh + - name: Fetch - precice develop uses: actions/checkout@v4 with: @@ -78,6 +82,12 @@ jobs: bundler-cache: true working-directory: website + - name: Patch jekyll-last-modified-at to respect frontmatter + working-directory: website + run: | + sed -i 's/item\.data\["last_modified_at"\] = Determinator/item.data["last_modified_at"] ||= Determinator/' \ + vendor/bundle/ruby/*/gems/jekyll-last-modified-at-*/lib/jekyll-last-modified-at/hook.rb + - name: Build website working-directory: website env: diff --git a/inject_dates.sh b/inject_dates.sh new file mode 100644 index 00000000000..d7089930115 --- /dev/null +++ b/inject_dates.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# inject_dates.sh +# Run this from the website root before jekyll build. +# It goes into each submodule, finds every markdown file, +# gets its true last-commit date from git, and injects/updates +# the last_modified_at field in the frontmatter so that +# jekyll-last-modified-at uses the correct date instead of +# falling back to filesystem mtime. + +set -euo pipefail + +WEBSITE_ROOT="$(pwd)" + +git submodule foreach --recursive ' + echo "==> Processing submodule: $displaypath" + + # Loop over every markdown file tracked by this submodule + git ls-files "*.md" "*.markdown" | while IFS= read -r file; do + + # Get the last commit date for this specific file + last_date=$(git log -1 --date=format:"%Y-%m-%d %H:%M:%S" --pretty=format:"%cd" -- "$file" 2>/dev/null) + + # Skip if git returned nothing (untracked or no history) + [ -z "$last_date" ] && continue + + # Full path: parent repo root + submodule path + file + filepath="$toplevel/$displaypath/$file" + + # Skip if file does not exist on disk + [ -f "$filepath" ] || continue + + # Check if file starts with a YAML frontmatter block + if head -1 "$filepath" | grep -q "^---"; then + + # If last_modified_at already exists in frontmatter, replace it + if grep -q "^last_modified_at:" "$filepath"; then + sed -i "s|^last_modified_at:.*|last_modified_at: $last_date|" "$filepath" + + # Otherwise insert it after the opening --- line + else + sed -i "0,/^---/{s|^---|---\nlast_modified_at: $last_date|}" "$filepath" + fi + + else + # No frontmatter at all — prepend one + tmpfile=$(mktemp) + printf -- "---\nlast_modified_at: %s\n---\n" "$last_date" | cat - "$filepath" > "$tmpfile" + mv "$tmpfile" "$filepath" + fi + + done + + echo " done." +' + +echo "" +echo "All submodule dates injected successfully." \ No newline at end of file From 4ed24734abef093ba4a848265708ef7c0a30ec54 Mon Sep 17 00:00:00 2001 From: Aayushman-nvm Date: Tue, 24 Feb 2026 11:56:35 +0000 Subject: [PATCH 3/3] fix: fetch full history for submodules to fix incorrect last-modified dates --- .github/workflows/deploy.yml | 15 ++++++++++----- inject_dates.sh | 26 +++++++++++--------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c2fb9b56590..adf0acb18cd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -37,9 +37,7 @@ jobs: - name: Fetch full history for submodules working-directory: website - run: | - git submodule foreach --recursive "git fetch --unshallow 2>/dev/null || true" - git submodule foreach --recursive "git fetch --all" + run: git submodule foreach --recursive "git fetch --unshallow --all 2>/dev/null || git fetch --all" - name: Inject last_modified_at dates from submodules working-directory: website @@ -85,8 +83,15 @@ jobs: - name: Patch jekyll-last-modified-at to respect frontmatter working-directory: website run: | - sed -i 's/item\.data\["last_modified_at"\] = Determinator/item.data["last_modified_at"] ||= Determinator/' \ - vendor/bundle/ruby/*/gems/jekyll-last-modified-at-*/lib/jekyll-last-modified-at/hook.rb + set -euo pipefail + shopt -s nullglob + hook_files=(vendor/bundle/ruby/*/gems/jekyll-last-modified-at-*/lib/jekyll-last-modified-at/hook.rb) + if [ "${#hook_files[@]}" -ne 1 ]; then + echo "Expected exactly one jekyll-last-modified-at hook.rb file, found ${#hook_files[@]}:" >&2 + printf ' %s\n' "${hook_files[@]}" >&2 + exit 1 + fi + sed -i 's/item\.data\["last_modified_at"\] = Determinator/item.data["last_modified_at"] ||= Determinator/' "${hook_files[0]}" - name: Build website working-directory: website diff --git a/inject_dates.sh b/inject_dates.sh index d7089930115..6de8156b1b7 100644 --- a/inject_dates.sh +++ b/inject_dates.sh @@ -9,45 +9,41 @@ set -euo pipefail -WEBSITE_ROOT="$(pwd)" - git submodule foreach --recursive ' echo "==> Processing submodule: $displaypath" - # Loop over every markdown file tracked by this submodule git ls-files "*.md" "*.markdown" | while IFS= read -r file; do - # Get the last commit date for this specific file last_date=$(git log -1 --date=format:"%Y-%m-%d %H:%M:%S" --pretty=format:"%cd" -- "$file" 2>/dev/null) - # Skip if git returned nothing (untracked or no history) - [ -z "$last_date" ] && continue + if [ -z "$last_date" ]; then + echo " SKIP (no git date): $file" + continue + fi - # Full path: parent repo root + submodule path + file filepath="$toplevel/$displaypath/$file" - # Skip if file does not exist on disk - [ -f "$filepath" ] || continue + if [ ! -f "$filepath" ]; then + echo " SKIP (not on disk): $file" + continue + fi - # Check if file starts with a YAML frontmatter block - if head -1 "$filepath" | grep -q "^---"; then + if awk '\''NR==1 { if ($0 == "---") { in_front=1; next } else { exit 1 } } in_front && NR>1 && $0 == "---" { exit 0 } END { exit 1 }'\'' "$filepath"; then - # If last_modified_at already exists in frontmatter, replace it if grep -q "^last_modified_at:" "$filepath"; then sed -i "s|^last_modified_at:.*|last_modified_at: $last_date|" "$filepath" - - # Otherwise insert it after the opening --- line else sed -i "0,/^---/{s|^---|---\nlast_modified_at: $last_date|}" "$filepath" fi else - # No frontmatter at all — prepend one tmpfile=$(mktemp) printf -- "---\nlast_modified_at: %s\n---\n" "$last_date" | cat - "$filepath" > "$tmpfile" mv "$tmpfile" "$filepath" fi + echo " OK: $file -> $last_date" + done echo " done."