fr: synchronize with enc 637d334.
[enc-live.git] / copy-enc-to-live
1 #! /bin/bash
2
3 # Copy Email Self-Defense translations locally from enc to enc-live.
4 # and update the language pickers.
5 # The two repos are assumed to have the same parent directory.
6 # The script is called from the root of enc-live:
7 # copy-enc-to-live LANG
8
9 # ***** Check that lang-picker-source is up to date. *****
10
11 set -e
12
13 lang=$1
14 pages='confirmation.html index.html infographic.html next_steps.html workshops.html'
15
16 test -n "$lang" || (echo " !!! Please enter a language code as argument.";
17 exit 1)
18
19 # The files we need are on the master branch of enc.
20 cd ../enc
21 git co master
22 # Get the ID of the last commit on this branch for future reference, and
23 # truncate it to 7 digits.
24 commit=$(git rev-parse HEAD | cut -b -7)
25
26 # Go back to enc-live.
27 cd ../enc-live
28 # Create the LANG directory if it doesn't exist.
29 mkdir -p $lang
30
31 # Take one page at a time.
32 for p in $pages; do
33 echo $lang/$p
34 # If it exists in enc,
35 if [ -f ../enc/$lang/$p ]; then
36 # copy it to enc-live.
37 cp ../enc/$lang/$p $lang/
38 # If not...
39 else
40 # say so,
41 echo " !!! $lang/$p doesn't exist"
42 # restore enc-live to its original state,
43 git reset --hard HEAD
44 # and quit.
45 exit 1
46 fi
47 done
48
49 # Add and commit the changes.
50 git add $lang
51 # Refer to the enc commit ID in the enc-live commit message.
52 git commit -m "$lang: synchronize with enc $commit."
53
54 replace-lang-picker
55 git commit --amend
56