forked from unfoldingWord-dev/Door43
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_obs_languages.sh
68 lines (53 loc) · 1.63 KB
/
update_obs_languages.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
# -*- coding: utf8 -*-
#
# Copyright (c) 2015 unfoldingWord
# http://creativecommons.org/licenses/MIT/
# See LICENSE file for details.
#
# Contributors:
# Richard Mahn <richard_mahn@wycliffeassociates.org>
#
# Usage: update_obs_languages.sh (that's it, will find all language repos that have obs and update all of them)
# DEBUG - true/false - If true, will run "set -x"
: ${DEBUG:=false}
# If running in DEBUG mode, output information about every command being run
$DEBUG && set -x
: ${DOOR43_DIR:=$(cd $(dirname "$0") > /dev/null && pwd)}
if [ -z $1 ];
then
# Let the person running the script know what's going on.
echo "Pulling in latest changes for all language repositories..."
# going to the parent directory
pushd "$DOOR43_DIR/data/gitrepo/pages" > /dev/null
# Find all git repositories with obs and update it to the master latest revision
for dir in $(find . -maxdepth 2 -type d -name "obs" | cut -c 3- | sort -u); do
echo "";
echo "Updateing $(dirname "$dir")";
# We have to go to the obs parent directory to call the pull command
pushd "$dir/.." > /dev/null;
# we don't want any changes in a development language branch
git fetch --all
git reset --hard origin/master
# lets get back main directory
popd > /dev/null
done
popd > /dev/null
else
for arg in "$@"
do
dir="$DOOR43_DIR/data/gitrepo/pages/$arg"
echo $dir
if [ ! -e $dir ];
then
echo "No such language: $arg";
exit 1;
fi
pushd $dir > /dev/null
git fetch --all
git reset --hard origin/master
popd > /dev/null
done
fi
echo "Done!"
echo ""