forked from rejoe2/FHEM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit
26 lines (18 loc) · 812 Bytes
/
pre-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
echo "Executing pre-commit hook at $(pwd)"
controls_file="controls_echodevice.txt"
changed_file="CHANGED"
# my $ModulVersion = "0.0.51h";
current_version=$(perl -0777 -ne 'print "$1" if /\$ModulVersion\s*=\s*\"(.+\..+\..+)\"\;/' FHEM/37_echodevice.pm)
find . -type f -iname '.DS_Store' -delete
test -e "${controls_file}" && rm "${controls_file}"
find -type f \( -path "./FHEM/*" -o -path './www/*' \) -print0 | while IFS= read -r -d '' f;
do
echo "DEL ${f}" >> ${controls_file}
out="UPD "$(stat -c %y $f | cut -d. -f1 | awk '{printf "%s_%s",$1,$2}')" "$(stat -c %s $f)" ${f}"
echo ${out//.\//} >> ${controls_file}
done
rm ${changed_file}
echo "Current version: ${current_version} from $(date +%d.%m.%Y)" > ${changed_file}
git add $controls_file
git add $changed_file