Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit4164b91eecbe35544fcc7e06329c3f66e528dc21 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-10-16 18:27:07 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-10-16 18:27:07 +0300
Files1069de6440d740fa599835677f18ec7838495d30
csg-4164b91eecbe35544fcc7e06329c3f66e528dc21.tar
csg-4164b91eecbe35544fcc7e06329c3f66e528dc21.tar.gz
csg-4164b91eecbe35544fcc7e06329c3f66e528dc21.zip
Parentf7f89e48b91f3cf1ff75dd61e5d5b70b7cb98ec5 (diff)
(s0) Reworked timestamps generation to work better
1 files changed, 23 insertions, 13 deletions
-rwxr-xr-xcsg36
diff --git a/csg b/csg
index fe6a6f8..ac41dc8 100755
--- a/csg
+++ b/csg
@@ -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