-
Notifications
You must be signed in to change notification settings - Fork 1
/
pull.sh
executable file
·71 lines (64 loc) · 1.41 KB
/
pull.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
68
69
70
#! /bin/bash
cd "$(dirname "$0")"
if [ -z "$(ls -A invesdwin-bom)" ]
then
./pull_fallback.sh
fi
git pull
git submodule init
OUTER_BRANCH=$(git branch --show-current 2> /dev/null)
if [ -z "$OUTER_BRANCH" ]
then
OUTER_BRANCH=$(git rev-parse --abbrev-ref HEAD)
fi
for dir in *
do
test "dependencies" = "$dir" && continue
test -d "$dir" || continue
echo -- $dir
cd $dir
if [ -z "$(ls -A .)" ]; then
echo -- $moduleDir -- git submodule update --init --recursive --remote .
git submodule update --init --recursive --remote .
echo -- $moduleDir -- git checkout $OUTER_BRANCH
git checkout $OUTER_BRANCH
fi
if [[ `git status --porcelain` ]]; then
# changes
LOCALCHANGES=1
else
# no changes
LOCALCHANGES=0
fi
if [ $LOCALCHANGES == 1 ]
then
echo -- $dir -- stashing
git stash
fi
BRANCH=$(git branch --show-current 2> /dev/null)
if [ -z "$BRANCH" ]
then
BRANCH=$(git rev-parse --abbrev-ref HEAD)
fi
if [ -z "$BRANCH" ]
then
BRANCH=$OUTER_BRANCH
fi
echo -- $moduleDir -- git checkout $BRANCH
git checkout $BRANCH
echo -- $dir -- pulling
git pull
if $(git rev-parse --is-shallow-repository); then
echo -- $dir -- fetching shallow branches
git remote set-branches origin '*'
git fetch -v --depth=1
fi
if [ $LOCALCHANGES == 1 ]
then
echo -- $dir -- popping stash
git stash pop
fi
cd ..
done
cd dependencies
./pull.sh