#!/bin/sh

# Download and commit the latest Transifex translations
#

# Exit on error or uncommitted changes
# TODO: check that master matches upstream/master
set -e
if [ ! -z "$(git status --porcelain -uno)" ]; then
  echo "Aborted: git working directory is not clean."
  exit 1
fi

echo "\n*** Checking out latest master... ***\n"
git checkout master
git pull upstream master

echo "\n*** Downloading latest Transifex translations... ***\n"
tx pull --force
git commit -a -m "Update all locales with the latest Transifex translations"

echo "\n*** Pushing to master... ***\n"
git push upstream master
