-
Notifications
You must be signed in to change notification settings - Fork 4
/
zanata-translate-pull
executable file
·110 lines (100 loc) · 2.85 KB
/
zanata-translate-pull
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash -eu
shopt -s globstar
### NAME
### zanata-translate-pull Download zanata translation.
###
### SYNOPSIS
### zanata-translate-pull [Options] [<module>|<artifact> [<branch> [ZanataMvnOption]]]
###
### OPTIONS
### -h: Show this help
###
### -B: Batch mode
### It will NOT ask question and proceed with default choice.
###
### -j: Just use current directory.
### This assumes that current directory is <module> work directory.
### and correct branch is checked out.
###
### -p: Push after commit
### Git push when it has commit.
###
### DESCRIPTION
### This program performs branching chores for big releases of
### zanata-client and zanata-server.
###
SCRIPT_DIR=$(dirname $(readlink -q -f $0))
FUNCTION_SCRIPT_FILE=${SCRIPT_DIR}/zanata-functions
source "${FUNCTION_SCRIPT_FILE}"
trap exit_print_error EXIT
PROGRAM_NAME=$(basename $0)
##=== parsing Start ===
print_status -t parsing -s "Start"
BatchMode=0
JustUseCurrentDirectoryMode=0
PushMode=0
while getopts "hBjp" opt;do
case $opt in
h )
zanata_script_help $0
exit ${EXIT_OK}
;;
B )
BatchMode=1
;;
j )
JustUseCurrentDirectoryMode=1
;;
p )
PushMode=1
;;
* )
failed ${EXIT_FATAL_INVALID_OPTIONS} "$opt"
;;
esac
done
export JustUseCurrentDirectoryMode
shift $((OPTIND-1))
## Get Module
branch_prepare RELEASING "$@"
shift $ShiftOffset
print_status " Module=$Module"
##=== prepare Start ===
print_status -t prepare -s "Start"
## Find zanata.xml
## TODO enable server/gwt-editor/zanata.xml when it is ready
ZanataXmlArray=( server/zanata.xml )
if [[ -z $ZanataXmlArray ]];then
failed $EXIT_FATAL_MISSING_DEPENDENCY "zanata.xml does not exist"
fi
##=== translation update Start ===
### Perhaps the zanata-maven-plugin does not deployed yet.
mvn -B install -pl .,client -DskipTests
for ZanataXml in "${ZanataXmlArray[@]}";do
d=$(dirname $ZanataXml)
cd $d
print_status -t "$d translation update" -s "Start"
print_status " pull translation from Zanata"
mvn -B -e org.zanata:zanata-maven-plugin:pull -pl . -Dzanata.projectVersion=$WorkingBranch $@
print_status " Validate translation"
if [[ -d zanata-war ]];then
mvn -B -e com.googlecode.l10n-maven-plugin:l10n-maven-plugin:validate -pl zanata-war $@
else
mvn -B -e com.googlecode.l10n-maven-plugin:l10n-maven-plugin:validate $@
fi
cd -
done
if ! git diff --exit-code ;then
if [ $BatchMode -eq 0 ];then
read -p "### Press [Ctrl-C] to break, [Enter] to continue"
fi
git commit -a -m "trans(pull): Update translation"
if [ $PushMode -ge 1 ];then
git push
else
exit ${EXIT_RETURN_FALSE}
fi
else
print_status " No change detected"
fi
exit ${EXIT_OK}