forked from adobe/brackets
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to pull string changes from thimble on build
- Loading branch information
Gideon Thomas
committed
Mar 8, 2016
1 parent
bcbc027
commit 7d9b8aa
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/*global process */ | ||
|
||
var request = require("request"); | ||
|
||
request({ | ||
uri: "https://api.github.com/repos/mozilla/brackets/contents/" + process.argv[2], | ||
method: "GET", | ||
headers: { | ||
"User-Agent": "gideonthomas" | ||
} | ||
}, function(err, res, body) { | ||
"use strict"; | ||
|
||
if(!err && res.statusCode === 200) { | ||
try { | ||
var content = JSON.parse(body); | ||
process.stdout.write(content.sha); | ||
} catch(e) { | ||
console.error("Failed to convert response to JSON with: ", e); | ||
process.exit(0); | ||
} | ||
} else { | ||
console.error("Failed to get file contents with: ", err || body); | ||
process.exit(0); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
set -e # exit with nonzero exit code if anything fails | ||
|
||
if [ "$UPDATE_STRINGS" == "true" ] | ||
then | ||
# Get the latest tarball of Thimble and extract the locales/ directory | ||
curl -L https://api.github.com/repos/mozilla/thimble.mozilla.org/tarball/master | \ | ||
tar -xv --include '/locales/' --strip-components 1 | ||
|
||
git add locales | ||
|
||
CHANGED="$(git diff --cached --name-only --diff-filter=M locales)" | ||
ADDED="$(git diff --cached --name-only --diff-filter=A locales)" | ||
|
||
for CHANGED_FILE in $CHANGED | ||
do | ||
sha="$(node scripts/get-file-sha.js $CHANGED_FILE)" | ||
locale="$(echo $CHANGED_FILE | sed -e 's/locales\///g' -e 's/\/editor\.properties//g')" | ||
content="$(base64 $CHANGED_FILE)" | ||
body="{ \ | ||
\"message\": \"Thimble-L10N - Update strings for $locale\", \ | ||
\"content\": \"$content\", \ | ||
\"sha\": \"$sha\" \ | ||
}" | ||
|
||
curl --location-trusted -X PUT \ | ||
-H "Content-Type: application/json" \ | ||
-H "Accept: application/json" \ | ||
-H "Authorization: token $GH_TOKEN" \ | ||
-d "$body" | ||
"https://api.github.com/repos/mozilla/brackets/contents/$CHANGED_FILE" | ||
|
||
echo "Successfully updated strings for $locale" | ||
done | ||
|
||
for ADDED_FILE in $ADDED | ||
do | ||
locale="$(echo $ADDED_FILE | sed -e 's/locales\///g' -e 's/\/editor\.properties//g')" | ||
content="$(base64 $ADDED_FILE)" | ||
body="{ \ | ||
\"message\": \"Thimble-L10N - Add strings for $locale\", \ | ||
\"content\": \"$content\", \ | ||
}" | ||
|
||
curl --location-trusted -X PUT \ | ||
-H "Content-Type: application/json" \ | ||
-H "Accept: application/json" \ | ||
-H "Authorization: token $GH_TOKEN" \ | ||
-d "$body" | ||
"https://api.github.com/repos/mozilla/brackets/contents/$ADDED_FILE" | ||
echo "Successfully added strings for $locale" | ||
done | ||
|
||
git reset locales | ||
fi |