From f07abaff3aea9431ae14afddd7de0223335c4a84 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 9 Jul 2025 10:35:41 -0500 Subject: [PATCH] ci: Set file mtimes from git log Every time the job runs, the _Publish_ stage changes the timestamps of the files on the server, even if their contents haven't changed. This is because each build runs from a fresh checkout, so every file appears to have just been created. To avoid this, and leave files on the server alone unless they've changed, we now set the modification timestamp of every file from its last commit. --- .rsync-filter | 1 + ci/Jenkinsfile | 1 + fixtimes.sh | 8 ++++++++ 3 files changed, 10 insertions(+) create mode 100755 fixtimes.sh diff --git a/.rsync-filter b/.rsync-filter index c294b39..d10744a 100644 --- a/.rsync-filter +++ b/.rsync-filter @@ -3,5 +3,6 @@ - *.j2 - .gitignore - Makefile +- fixtimes.sh - publish.sh - render.py diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index cefdad6..24ed5aa 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -10,6 +10,7 @@ pipeline { stages { stage('Build') { steps { + sh './fixtimes.sh' sh 'make' } } diff --git a/fixtimes.sh b/fixtimes.sh new file mode 100755 index 0000000..658d7b4 --- /dev/null +++ b/fixtimes.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +git ls-files | while IFS= read -r file; do + ts=$(git log -1 --format=%at -- "${file}") + if [ -n "${ts}" ]; then + touch -d "@${ts}" -- "${file}" + fi +done