forked from xwiki-contrib/application-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-translations.sh
executable file
·84 lines (70 loc) · 2.56 KB
/
release-translations.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
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
#!/bin/bash
BRANCH=master
USER="$L10N_USER"
PASS="$L10N_PASSWORD"
XWIKI_TRUNKS=`pwd`
function fix_author() {
find ./ -name '*.xml' -exec sed -i -e 's#<creator>XWiki.Admin</creator>#<creator>xwiki:XWiki.Admin</creator>#' -e 's#<author>XWiki.Admin</author>#<author>xwiki:XWiki.Admin</author>#' -e 's#<contentAuthor>XWiki.Admin</contentAuthor>#<contentAuthor>xwiki:XWiki.Admin</contentAuthor>#' {} \; -print
}
function do_one() {
wget $1 --user="${USER}" --password="${PASS}" --auth-no-challenge -O ./translations.zip &&
unzip -o translations.zip &&
rm translations.zip || $(git clean -dxf && exit -1)
fix_author
}
function read_user_and_password() {
if [[ -z "$USER" || -z "$PASS" ]]; then
printf "\033[0;32mEnter your l10n.xwiki.org credentials:\033[0m\n"
read -e -p "user> " USER
read -e -s -p "pass> " PASS
printf "\n"
fi
if [[ -z "$USER" || -z "$PASS" ]]; then
printf "\033[1;31mPlease provide both user and password in order to be able to get the translations from l10n.xwiki.org.\033[0m\n"
exit -1
fi
}
function format_xar() {
## due to https://github.com/mycila/license-maven-plugin/issues/37 we need to perform "mvn xar:format" twice.
mvn xar:format
mvn xar:format
}
function do_all() {
read_user_and_password
if [[-f ${XWIKI_TUNKS}/application-blog-notification ]]; then
cd ${XWIKI_TRUNKS}/application-blog-notification/src/main/resources/ || exit -1
do_one 'http://l10n.xwiki.org/xwiki/bin/view/L10NCode/GetTranslationFile?name=Contrib.Blog%20API%20Resources&app=Contrib'
fi
cd ${XWIKI_TRUNKS}/application-blog-ui/src/main/resources/ || exit -1
do_one 'http://l10n.xwiki.org/xwiki/bin/view/L10NCode/GetTranslationFile?name=Contrib.BlogTranslations&app=Contrib'
cd ${XWIKI_TRUNKS}/application-blog-ui/ && format_xar
git status
printf "\033[0;32mIf there are untracked files, something probably went wrong.\033[0m\n"
}
function check_clean() {
if [[ `git status --porcelain` ]]; then
# changes
git status
printf "\033[1;31mPlease do something with these changes first.\033[0m\n"
printf "\033[1;31min `pwd`\033[0m\n"
exit -1;
else
git reset --hard &&
git checkout ${BRANCH} &&
git reset --hard &&
git clean -dxf &&
git pull origin ${BRANCH} || exit -1
fi
}
function commit() {
MSG="[release] Updated translations."
git add . && git commit -m "${MSG}" && git push
}
if [[ $1 == 'commit' ]]; then
commit
elif [[ $1 == 'clean' ]]; then
git reset --hard && git clean -dxf
else
check_clean
do_all
fi