Summary Files Commits Branches @commit @diff @stats
path: root / .hooks / pre-commit.sh
blob: 5ddef4a965d5f14e7d7f8474e05403d95283b8f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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