-
Notifications
You must be signed in to change notification settings - Fork 21
/
update.sh
47 lines (44 loc) · 1.33 KB
/
update.sh
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
42
43
44
45
46
47
set -u
last_commit=adc81a00817cae675ea26c71ba63090c90a5a27b
git_root=$(git rev-parse --show-toplevel)
function update_language()
{
language=$1
echo update for $language
head_dir=website/translated_docs/$language
[[ $language = "en" ]] && head_dir=docs
if [ ! -d $git_root/$head_dir ]
then
echo "invalid language $language $head_dir"
exit 1
fi
updates=`git diff --name-only $last_commit --|grep "^$head_dir"|grep -v version|grep "md$"`
for item in $updates
do
doc_name=`echo $item|sed "s#$head_dir/##"`
if [ "$language" == "en" ]
then
#cd $git_root/$head_dir
#git diff --no-color --no-prefix --relative=$head_dir $last_commit HEAD $doc_name > $tmpfile
#patch -p0 < $tmpfile
cd $git_root/website/versioned_docs
version=`find version* |grep $doc_name|sort|tail -n 1|cut -d/ -f1`
echo update $doc_name at version $version
cd $version
tmpfile=/tmp/lispczz_`basename $doc_name`
head -n 6 $doc_name > $tmpfile
tail -n +6 $git_root/$head_dir/$doc_name >> $tmpfile
#echo cp $tmpfile $doc_name
cp $tmpfile $doc_name
else
cd $git_root/$head_dir
version=`find version* |grep $doc_name|sort|tail -n 1|cut -d/ -f1`
echo update $doc_name at version $version
echo cp $doc_name $version/$doc_name
cp $doc_name $version/$doc_name
fi
done
}
update_language en
update_language zh-CN
#update_language ja