From beb963d3418fb4c574365d4939361aebcc842652 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 2 Oct 2020 22:50:44 -0700 Subject: [PATCH] Add a tool to be able to set file timestamps to git commit dates. This will eventually be used to help improve arduino caching behavior --- bin/set-timestamps-from-git | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bin/set-timestamps-from-git diff --git a/bin/set-timestamps-from-git b/bin/set-timestamps-from-git new file mode 100644 index 00000000..05b569bc --- /dev/null +++ b/bin/set-timestamps-from-git @@ -0,0 +1,16 @@ +#!/bin/bash -e + +# This script sets all of the files inside src and example to have mtimes +# that match the times of the last git commit that touched each file + +# This can be useful when build tools depend on file timestamps to +# make caching decisions + +for file in `find src examples -type f` +do + timestamp=$(git log --pretty=format:%ad --date=format:%Y%m%d%H%M.%S -n 1 HEAD "$file" 2> /dev/null) + if [ "x$timestamp" != "x" ]; then + touch -t "$timestamp" "$file" + fi +done +