diff options
| author | Mirek Kratochvil <miroslav.kratochvil@uni.lu> | 2023-06-22 11:29:39 +0200 |
|---|---|---|
| committer | Mirek Kratochvil <miroslav.kratochvil@uni.lu> | 2023-06-22 11:43:28 +0200 |
| commit | 91900a323ca89592c200e55dc8afc65c8a9abe3a (patch) | |
| tree | 1850adafd1bf427d549fa2b6509230ae5a1cf8ee /scripts/source-timestamps.sh | |
| parent | 65944a1cdfe3c06df737e5c54aec43292d0180bf (diff) | |
| download | reploy-91900a323ca89592c200e55dc8afc65c8a9abe3a.tar.gz reploy-91900a323ca89592c200e55dc8afc65c8a9abe3a.tar.bz2 | |
add a script for sourcing the timestamps from gits
Fixes #2
Diffstat (limited to 'scripts/source-timestamps.sh')
| -rwxr-xr-x | scripts/source-timestamps.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/source-timestamps.sh b/scripts/source-timestamps.sh new file mode 100755 index 0000000..74ff9f0 --- /dev/null +++ b/scripts/source-timestamps.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# change this with environment +DEFAULT_NOT_SOURCE_REGEX="/\\/assets\\//" +NOT_SOURCE_REGEX="${NOT_SOURCE_REGEX:-$DEFAULT_NOT_SOURCE_REGEX}" +TIMESTAMP_SUFFIX="${SUFFIX:-.timestamp}" +LOGFILE="${LOGFILE:-/dev/null}" + +[ -z "$1" ] && echo "$0: no inputs specified?" >/dev/stderr + +while [ -n "$1" ] +do + echo "sourcing directory '$1' ..." >> "$LOGFILE" + find "$1" -type f -name '*.md' | grep -v "$NOT_SOURCE_REGEX" | while read file ; do + fn=`basename "$file"` + dir=`dirname "$file"` + tsfn="$fn.timestamp" + ( + echo "making timestamp in '$dir' for file '$fn' ..." >> "$LOGFILE" + cd "$dir" + if [ -f "$tsfn" ] + then echo "... but it already exists; skipping!" >> "$LOGFILE" + else git log -n 1 --pretty=format:%cs -- "$fn" > "$tsfn" + fi + ) + done + shift +done |
