#! /bin/bash # Copy Email Self-Defense translations locally from enc to enc-live. # and update the language pickers. # The two repos are assumed to have the same parent directory. # The script is called from the root of enc-live: # copy-enc-to-live LANG # ***** Check that lang-picker-source is up to date. ***** set -e lang=$1 pages='confirmation.html index.html infographic.html next_steps.html workshops.html' test -n "$lang" || (echo " !!! Please enter a language code as argument."; exit 1) # The files we need are on the master branch of enc. cd ../enc git co master # Get the ID of the last commit on this branch for future reference, and # truncate it to 7 digits. commit=$(git rev-parse HEAD | cut -b -7) # Go back to enc-live. cd ../enc-live # Create the LANG directory if it doesn't exist. mkdir -p $lang # Take one page at a time. for p in $pages; do echo $lang/$p # If it exists in enc, if [ -f ../enc/$lang/$p ]; then # copy it to enc-live. cp ../enc/$lang/$p $lang/ # If not... else # say so, echo " !!! $lang/$p doesn't exist" # restore enc-live to its original state, git reset --hard HEAD # and quit. exit 1 fi done # Add and commit the changes. git add $lang # Refer to the enc commit ID in the enc-live commit message. git commit -m "$lang: synchronize with enc $commit." replace-lang-picker git commit --amend