forked from ckrf/xlsx-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-commit
executable file
·41 lines (34 loc) · 933 Bytes
/
post-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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
#
# post-commit-excel: have git handle xlsx files by deflating them and storing
# the XML in the repository, not the zip file.
#
# companion to pre-commit-excel
# currently identical to post-checkout
# -- config -- #
TMP_PREFIX='.~' # prefix XML directory--should NOT conflict with
# anything in your repo
# -- end config -- #
echo
echo "=== Post-commit XLSX processing ===="
repack_xlsx () {
# re-zip the XML directory
rm "$1"
cd "${TMP_PREFIX}$1"
zip "../$1" -r *
cd ..
}
# make it easy to iterate over subdirectories
shopt -s globstar
# repack all the zipfiles
start_dir="$(pwd)"
for i in **/${TMP_PREFIX}*.xlsx; do
dir=$(dirname "$i")
base=$(basename "$i")
file=${base:${#TMP_PREFIX}}
cd "$dir"
repack_xlsx "$file"
cd "$start_dir"
done
echo "=== End of post-commit processing ==="
echo