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
1 change: 1 addition & 0 deletions .github/workflows/branch-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
run: |
pip3 install --upgrade jupyter
ruby test/cache_bust_test.rb
ruby test/repository_last_updated_test.rb
export JEKYLL_ENV=production
bundle exec jekyll build
- name: Purge unused CSS 🧹
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
run: |
pip3 install --upgrade jupyter
ruby test/cache_bust_test.rb
ruby test/repository_last_updated_test.rb
export JEKYLL_ENV=production
bundle exec jekyll build
- name: Purge unused CSS 🧹
Expand Down
2 changes: 1 addition & 1 deletion _layouts/about.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,5 @@ layout: default
</div>
</div>

<div class="homepage-footer">© All right reserved. Last updated on July 10, 2026</div>
<div class="homepage-footer">© All right reserved. Last updated on {{ site.repository_last_updated_at | date: '%B %-d, %Y' }}</div>
</div>
19 changes: 19 additions & 0 deletions _plugins/repository-last-updated.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Derive the site's update date from the commit being built, not the build clock.
require 'open3'

module Jekyll
class RepositoryLastUpdatedGenerator < Generator
priority :highest

def generate(site)
timestamp, status = Open3.capture2('git', 'log', '-1', '--format=%cI', 'HEAD', chdir: site.source)
timestamp = timestamp.strip

unless status.success? && !timestamp.empty?
raise 'Could not determine the repository HEAD commit date'
end

site.config['repository_last_updated_at'] = timestamp
end
end
end
50 changes: 50 additions & 0 deletions test/repository_last_updated_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# AI-generated regression coverage for the build-time repository update date.
require 'fileutils'
require 'minitest/autorun'
require 'tmpdir'

module Jekyll
class Generator
def self.priority(_priority); end
end
end

require_relative '../_plugins/repository-last-updated'

class RepositoryLastUpdatedGeneratorTest < Minitest::Test
Site = Struct.new(:source, :config)

def setup
@tmpdir = Dir.mktmpdir('repository-last-updated-test')
git('init', '--quiet')
git('config', 'user.name', 'Test User')
git('config', 'user.email', 'test@example.com')
File.write(File.join(@tmpdir, 'index.md'), 'test')
git('add', 'index.md')
git(
'commit', '--quiet', '-m', 'Test commit',
env: {
'GIT_AUTHOR_DATE' => '2026-07-12T09:10:11Z',
'GIT_COMMITTER_DATE' => '2026-07-13T12:35:52+08:00'
}
)
end

def teardown
FileUtils.remove_entry(@tmpdir)
end

def test_exposes_head_committer_timestamp_to_liquid
site = Site.new(@tmpdir, {})

Jekyll::RepositoryLastUpdatedGenerator.new.generate(site)

assert_equal '2026-07-13T12:35:52+08:00', site.config['repository_last_updated_at']
end

private

def git(*arguments, env: {})
system(env, 'git', *arguments, chdir: @tmpdir, exception: true)
end
end
Loading