diff options
1 files changed, 23 insertions, 13 deletions
| -rwxr-xr-x | csg | 36 |
@@ -5,25 +5,35 @@ SOURCE="$2" OUTPUT="$(realpath "$3")" TITLEF="$4" -TIMESTAMPS="timestamps.txt" +TIMESTAMPS="$(realpath ./timestamps.txt)" -# $1 - file path -# $2 - stat file -# Line is in the format: name¶created¶edited -gitStats() { - local dates=($(git log --follow --pretty=format:%ad --date="format:%d %B %Y" -- $1)) - local line="./website${file:5:-2}html¶${dates[@]: -3:3}¶${dates[@]:0:3}" - echo -e $line >> $2 +### Helper functions + +isCommand() { + command -v "$1" &> /dev/null } -headc=$(git rev-parse HEAD) -update_timestamps="" -if [ ! -f "$TIMESTAMPS" ] || [ "$headc" != "$(head -1 "$TIMESTAMPS")" ]; then - update_timestamps="1" - echo "$headc" > "$TIMESTAMPS" +overwriteLine() { ### Stage 0 ### Create timestamps.txt file, if necessary +if isCommand 'git' +then + timestamps_writeDates() { + for file in $(find . -type f -name '*.md') + do + dates=($(git log --follow --pretty=format:%ad --date="format:%d %B %Y" -- "$file")) + line="$OUTPUT${file:1:-2}html\t${dates[@]: -3:3}\t${dates[@]:0:3}" + echo -e $line >> "$TIMESTAMPS" + done + } + + headc=$(git rev-parse HEAD) + if [ ! -f "$TIMESTAMPS" ] || [ "$headc" != "$(head -1 "$TIMESTAMPS")" ] + then + echo "$headc" > "$TIMESTAMPS" + (cd "$SOURCE" && timestamps_writeDates) + fi fi # Copy from SOURCE to OUTPUT |
