Skip to content

Commit 9778704

Browse files
Merge pull request #795 from nextcloud/temp/test-depth-1-cloning
fix(translation): Clone only with depth=1
2 parents f922ae9 + 9cc1806 commit 9778704

File tree

2 files changed

+135
-63
lines changed

2 files changed

+135
-63
lines changed

translations-app/handleAppTranslations.sh

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@ gpg --allow-secret-key-import --import /gpg/nextcloud-bot.asc
99
gpg --list-keys
1010

1111
# fetch git repo
12-
git clone git@github.com:$1/$2 /app
12+
git clone git@github.com:$1/$2 /app/default --depth 1
1313

14-
if [ ! -f '/app/.tx/config' ]; then
14+
cd default
15+
16+
if [ ! -f '.tx/config' ]; then
1517
echo "Missing transifex configuration file .tx/config"
1618
exit 1
1719
fi
1820

21+
##################################
22+
# Migrate the transifex config to the new client version
23+
##################################
24+
tx migrate
25+
git add --force .tx/config
26+
rm .tx/config_*
27+
git commit -am "fix(l10n): Update Transifex configuration" -s || true
28+
git push
29+
30+
##################################
31+
# Validate sync setup
32+
##################################
1933
APP_ID=$(grep -oE '<id>.*</id>' appinfo/info.xml | head --lines 1 | sed -E 's/<id>(.*)<\/id>/\1/')
2034
IS_EX_APP=$(grep -q '<external-app>' appinfo/info.xml && grep -q '</external-app>' appinfo/info.xml && echo "true" || echo "false")
2135
RESOURCE_ID=$(grep -oE '\[o:nextcloud:p:nextcloud:r:.*\]' .tx/config | sed -E 's/\[o:nextcloud:p:nextcloud:r:(.*)\]/\1/')
@@ -31,32 +45,36 @@ if [ "$RESOURCE_ID" = "talk_desktop" ]; then
3145
APP_ID="talk_desktop"
3246
fi
3347

34-
# TODO use build/l10nParseAppInfo.php to fetch app names for l10n
35-
3648
versions='main master stable31 stable30'
37-
if [ -f '/app/.tx/backport' ]; then
38-
versions="main master $(cat /app/.tx/backport)"
49+
if [ -f '.tx/backport' ]; then
50+
versions="main master $(cat .tx/backport)"
3951
fi
4052

41-
# build POT files for all versions
4253
mkdir stable-templates
54+
mkdir -p translationfiles/templates/
55+
56+
##################################
57+
# Clone backport branches
58+
##################################
59+
# Don't fail on checking out non existing branches
60+
set +e
61+
for version in $versions
62+
do
63+
git clone git@github.com:$1/$2 /app/$version --depth 1 --branch $version
64+
done
65+
set -e
66+
67+
##################################
68+
# Build POT files for all versions
69+
##################################
4370
for version in $versions
4471
do
45-
# skip if the branch doesn't exist
46-
if git branch -r | egrep "^\W*origin/$version$" ; then
47-
echo "Valid branch: $version"
48-
else
49-
echo "Invalid branch: $version"
72+
if [ ! -d /app/$version ]; then
73+
# skip if the branch doesn't exist
5074
continue
5175
fi
52-
git checkout $version
5376

54-
# Migrate the transifex config to the new client version
55-
tx migrate
56-
git add --force .tx/config
57-
rm .tx/config_*
58-
git commit -am "fix(l10n): Update Transifex configuration" -s || true
59-
git push
77+
cd /app/$version
6078

6179
# build POT files
6280
/translationtool.phar create-pot-files
@@ -65,11 +83,17 @@ do
6583
for file in $(ls)
6684
do
6785
FILE_SAVE_VERSION=$(echo $version | sed -E 's/\//-/')
68-
mv $file ../../stable-templates/$FILE_SAVE_VERSION.$RESOURCE_ID.pot
86+
mv $file /app/default/stable-templates/$FILE_SAVE_VERSION.$RESOURCE_ID.pot
6987
done
7088
cd ../..
7189
done
7290

91+
92+
##################################
93+
# Sync with transifex
94+
##################################
95+
cd /app/default
96+
7397
# merge POT files into one
7498
for file in $(ls stable-templates/master.*)
7599
do
@@ -92,6 +116,9 @@ tx push -s
92116
# pull translations - force pull because a fresh clone has newer time stamps
93117
tx pull -f -a --minimum-perc=5
94118

119+
# delete removed l10n files that are used for language detection (they will be recreated during the write)
120+
rm -f l10n/*.js l10n/*.json
121+
95122
# Copy back the po files from transifex resource id to app id
96123
if [ "$RESOURCE_ID" = "$APP_ID" ] ; then
97124
echo 'App id and transifex resource id are the same, not renaming po files …'
@@ -112,34 +139,33 @@ else
112139
done
113140
fi
114141

142+
# build JS/JSON based on translations
143+
/translationtool.phar convert-po-files
144+
145+
##################################
146+
# Add translations to branches again
147+
##################################
115148
for version in $versions
116149
do
117-
# skip if the branch doesn't exist
118-
if git branch -r | egrep "^\W*origin/$version$" ; then
119-
echo "Valid branch"
120-
else
121-
echo "Invalid branch"
150+
if [ ! -d /app/$version ]; then
151+
# skip if the branch doesn't exist
122152
continue
123153
fi
124-
git checkout $version
154+
155+
cd /app/$version
125156

126157
# delete removed l10n files that are used for language detection (they will be recreated during the write)
127158
rm -f l10n/*.js l10n/*.json
128159

129-
# build JS/JSON based on translations
130-
/translationtool.phar convert-po-files
131-
132-
if [ -d tests ]; then
133-
# remove tests/
134-
rm -rf tests
135-
git checkout -- tests/
136-
fi
160+
# Copy JS and JSON
161+
cp /app/default/l10n/*.js /app/default/l10n/*.json l10n
137162

138163
# create git commit and push it
139164
git add l10n/*.js l10n/*.json
140165

141166
# for ExApps, we need to include .po translation files as well
142167
if [ "$IS_EX_APP" = "true" ]; then
168+
cp /app/default/translationfiles/*.po translationfiles
143169
git add translationfiles/*.po
144170
fi
145171

@@ -152,5 +178,8 @@ done
152178
# End of verbose mode
153179
set +xe
154180

155-
/validateTranslationFiles.sh
181+
##################################
182+
# Validate translations
183+
##################################
184+
/validateTranslationFiles.sh /app/default
156185
exit $?

translations/handleTranslations.sh

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,69 @@ gpg --allow-secret-key-import --import /gpg/nextcloud-bot.asc
99
gpg --list-keys
1010

1111
# fetch git repo
12-
git clone git@github.com:nextcloud/server /app
12+
git clone git@github.com:nextcloud/server /app/default --depth 1
1313

14+
##################################
1415
# Migrate the transifex config to the new client version
15-
cd /app
16+
##################################
17+
cd /app/default
1618
tx migrate
1719
git add .tx/config
1820
rm .tx/config_*
1921
git commit -am "fix(l10n): Update Transifex configuration" -s || true
2022
git push
21-
cd -
22-
23-
# TODO use build/l10nParseAppInfo.php to fetch app names for l10n
2423

24+
##################################
25+
# Prepare sync setup
26+
##################################
2527
versions='master stable31 stable30'
2628

27-
# build POT files for all versions
2829
mkdir stable-templates
30+
mkdir -p translationfiles/templates/
31+
32+
##################################
33+
# Clone backport branches
34+
##################################
35+
# Don't fail on checking out non existing branches
36+
set +e
37+
for version in $versions
38+
do
39+
git clone git@github.com:nextcloud/server /app/$version --depth 1 --branch $version
40+
done
41+
set -e
42+
43+
##################################
44+
# Build POT files for all versions
45+
##################################
2946
for version in $versions
3047
do
31-
# skip if the branch doesn't exist
32-
if git branch -r | egrep "^\W*origin/$version$" ; then
33-
echo "Valid branch"
34-
else
35-
echo "Invalid branch"
48+
if [ ! -d /app/$version ]; then
49+
# skip if the branch doesn't exist
3650
continue
3751
fi
3852

39-
git checkout $version
53+
cd /app/$version
4054

4155
# build POT files
4256
/translationtool.phar create-pot-files
4357

4458
cd translationfiles/templates/
4559
for file in $(ls)
4660
do
47-
mv $file ../../stable-templates/$version.$file
61+
mv $file /app/default/stable-templates/$version.$file
4862
done
4963
cd ../..
5064
done
5165

66+
##################################
67+
# Sync with transifex
68+
##################################
69+
cd /app/default
70+
5271
# merge POT files into one
5372
for file in $(ls stable-templates/master.*)
5473
do
74+
# Change below to 23 when server switches to main
5575
name=$(echo $file | cut -b 25- )
5676
msgcat --use-first stable-templates/*.$name > translationfiles/templates/$name
5777
done
@@ -72,28 +92,47 @@ tx pull -a -f -r nextcloud.lib --minimum-perc=0
7292
# pull 20% of "settings" translations for the region name
7393
tx pull -a -f -r nextcloud.settings-1 --minimum-perc=20
7494

95+
96+
# delete removed l10n files
97+
find core/l10n/*.js -type f -delete
98+
find core/l10n/*.json -type f -delete
99+
find lib/l10n/*.js -type f -delete
100+
find lib/l10n/*.json -type f -delete
101+
find apps/*/l10n/*.js -type f -delete
102+
find apps/*/l10n/*.json -type f -delete
103+
104+
# build JS/JSON based on translations
105+
/translationtool.phar convert-po-files
106+
107+
##################################
108+
# Add translations to branches again
109+
##################################
75110
for version in $versions
76111
do
77-
# skip if the branch doesn't exist
78-
if git branch -r | egrep "^\W*origin/$version$" ; then
79-
echo "Valid branch"
80-
else
81-
echo "Invalid branch"
112+
if [ ! -d /app/$version ]; then
113+
# skip if the branch doesn't exist
82114
continue
83115
fi
84116

85-
git checkout $version
117+
cd /app/$version
86118

87119
# delete removed l10n files that are used for language detection (they will be recreated during the write)
88-
find core/l10n -type f -delete
89-
find lib/l10n -type f -delete
90-
91-
# build JS/JSON based on translations
92-
/translationtool.phar convert-po-files
93-
94-
# remove tests/
95-
rm -rf tests
96-
git checkout -- tests/
120+
find core/l10n/*.js -type f -delete
121+
find core/l10n/*.json -type f -delete
122+
find lib/l10n/*.js -type f -delete
123+
find lib/l10n/*.json -type f -delete
124+
find apps/*/l10n/*.js -type f -delete
125+
find apps/*/l10n/*.json -type f -delete
126+
127+
# Copy JS and JSON
128+
cd /app/default
129+
find core/l10n/*.js -type f -exec cp {} /app/$version/{} \;
130+
find core/l10n/*.json -type f -exec cp {} /app/$version/{} \;
131+
find lib/l10n/*.js -type f -exec cp {} /app/$version/{} \;
132+
find lib/l10n/*.json -type f -exec cp {} /app/$version/{} \;
133+
find apps/*/l10n/*.js -type f -exec cp {} /app/$version/{} \;
134+
find apps/*/l10n/*.json -type f -exec cp {} /app/$version/{} \;
135+
cd /app/$version
97136

98137
# create git commit and push it
99138
git add apps core lib
@@ -104,6 +143,10 @@ do
104143
echo "done with $version"
105144
done
106145

146+
##################################
147+
# Validate translations
148+
##################################
149+
cd /app/default
107150
set +xe
108151
EXIT_CODE=0
109152
/validateTranslationFiles.sh core

0 commit comments

Comments
 (0)