Last active
February 17, 2017 03:37
-
-
Save kevingriffin/d59821446ce424a56c7da2686d4ae082 to your computer and use it in GitHub Desktop.
A driver for the phraseapp_updater gem. This driver uses git to maintain a history from PhraseApp and diff against it.
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
#!/bin/bash -e | |
PREFIX=config/locales | |
BRANCH=test-master | |
WORKING_DIRECTORY=/data/application | |
PA_API_KEY="" | |
PA_PROJECT_ID="" | |
cd ${WORKING_DIRECTORY} | |
git reset --hard | |
git fetch | |
git checkout --detach origin/phraseapp/${BRANCH} | |
PA_NEW_LOCALES_PATH=$(mktemp -d) | |
git archive --format=tar origin/${BRANCH}:${PREFIX} | tar -x -C ${PA_NEW_LOCALES_PATH} | |
# Find the nearest common ancestor of master and phraseapp (i.e. the last time # we ran this) | |
ORIGIN_COMMIT=$(git merge-base origin/${BRANCH} origin/phraseapp/${BRANCH}) | |
PA_PREVIOUS_LOCALES_PATH=$(mktemp -d) | |
git archive --format=tar ${ORIGIN_COMMIT}:${PREFIX} | tar -x -C ${PA_PREVIOUS_LOCALES_PATH} | |
# Fetch from phraseapp | |
PHRASEAPP_DIR=$(mktemp -d) | |
RESOLUTION_DIR=$(mktemp -d) | |
# Store the results in a temporary location to apply them after committing the original | |
# data downloaded from PhraseApp. | |
phraseapp_updater push --store_results_path=${RESOLUTION_DIR} --store_phraseapp_originals_path=${PHRASEAPP_DIR} | |
# Clean up | |
rm -r ${PA_NEW_LOCALES_PATH} ${PA_PREVIOUS_LOCALES_PATH} | |
# create a commit on phraseapp branch with the current contents of phraseapp | |
rm -r ${PREFIX} | |
mv ${PHRASEAPP_DIR} ${PREFIX} | |
git add -A ${PREFIX} | |
git commit -m "Imported remote changes from PhraseApp" | |
# Create a merge commit with the resolution of master and current-phraseapp | |
git merge -s ours --no-commit origin/${BRANCH} | |
rm -r ${PREFIX} | |
mv ${RESOLUTION_DIR} ${PREFIX} | |
git add -A ${PREFIX} | |
git commit -m "Merged ${BRANCH} changes to PhraseApp" | |
git push origin HEAD:refs/heads/phraseapp/${BRANCH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment