-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenableExcelDiff.sh
More file actions
executable file
·37 lines (33 loc) · 1.17 KB
/
enableExcelDiff.sh
File metadata and controls
executable file
·37 lines (33 loc) · 1.17 KB
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
#!/bin/bash
gitignoreFile=".gitignore"
gitAttributesFile=".gitattributes"
gitConfigFile=".git/config"
excel2txtPath="excel2txtTool/excel2TxtTools.py"
excel2txtCmd="python $excel2txtPath"
#gitattributes
if [ ! -f "$gitAttributesFile" ]; then
touch "$gitAttributesFile"
echo "*.xlsx diff=excel2txt_diff_tool" >> $gitAttributesFile
echo "*.xls diff=excel2txt_diff_tool" >> $gitAttributesFile
else
grep -q "*.xlsx diff=excel2txt_diff_tool" $gitAttributesFile
if [ $? -ne 0 ];then
echo "*.xlsx diff=excel2txt_diff_tool" >> $gitAttributesFile
fi
grep -q "*.xls diff=excel2txt_diff_tool" $gitAttributesFile
if [ $? -ne 0 ];then
echo "*.xls diff=excel2txt_diff_tool" >> $gitAttributesFile
fi
fi
#git config file
if [ -f "$gitConfigFile" ]; then
grep -q "\[diff \"excel2txt_diff_tool\"\]" $gitConfigFile
if [ $? -ne 0 ]
then
echo " " >> $gitConfigFile
echo "[diff \"excel2txt_diff_tool\"]" >> $gitConfigFile
echo " binary = true" >> $gitConfigFile
echo " textconv = ${excel2txtCmd}" >> $gitConfigFile
fi
fi
echo "excel2txt has been configured for git sucessfully. Making human-readable 'git diff' output for Excel files(*.xlsx or *.xls) possible."