Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitdc18126a9e9496f12642c8beb7a2fabd10b92453 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-04 18:10:15 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-04 18:10:15 +0300
Filesa7a7f4252825bf9d6f441df8046444bf59093af8
syndamia.com-dc18126a9e9496f12642c8beb7a2fabd10b92453.tar
syndamia.com-dc18126a9e9496f12642c8beb7a2fabd10b92453.tar.gz
syndamia.com-dc18126a9e9496f12642c8beb7a2fabd10b92453.zip
Parente4c13b86d566831e54301b1ca0144110782a83bf (diff)
Added pre-commit hook for fixing hard links to folder index.md files
1 files changed, 23 insertions, 0 deletions
-rwxr-xr-x.hooks/pre-commit.sh23
diff --git a/.hooks/pre-commit.sh b/.hooks/pre-commit.sh
new file mode 100755
index 0000000..5ddef4a
--- /dev/null
+++ b/.hooks/pre-commit.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# When copying/symlinking to .git/hooks/ remember to remove the filename extension!
+
+root='./src/'
+names=('about' 'archives' 'blog' 'docs' 'tutorials')
+
+changes=0
+for name in ${names[@]}; do
+ if ! cmp "$root$name.md" "$root$name/index.md" >/dev/null 2>&1; then
+ cd "$root$name"
+ if [ -f 'index.md' ]; then rm 'index.md'; fi
+ ln "../$name.md" 'index.md'
+ cd '../../'
+ changes=1
+ fi
+done
+
+if [ "$changes" -eq '1' ]; then
+ echo '#========================================================================#'
+ echo '# Index files have been fixed! Consider adding them into the commit too! #'
+ echo '#========================================================================#'
+fi