forked from PROGRAP/sw6-google-customer-reviews
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-preview.sh
executable file
·64 lines (47 loc) · 1.44 KB
/
git-preview.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
#!/usr/bin/env bash
echo "updating repo..."
git fetch -p > /dev/null
git checkout master &> /dev/null
git reset --hard origin/master > /dev/null
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -D &> /dev/null
BRANCHES=$(git branch -r --sort=committerdate | grep 'issues/')
echo "creating preview branch..."
git branch -f preview > /dev/null
git checkout preview &> /dev/null
while read -r ITEM; do
echo "including $ITEM"
git merge --no-ff $ITEM > /dev/null
if [ $? -ne 0 ]
then
echo "faild to merge $ITEM!"
echo "Canceling preview branch..."
git checkout master &> /dev/null
git branch -D preview &> /dev/null
exit 1
fi
done <<< "$BRANCHES"
if [[ "$(git submodule)" != "" ]]; then
echo "creating preview of submodules..."
create_preview=$(cat <<-END
if [[ ! -f './git-preview.sh' ]]; then
echo 'no preview script present!'
echo ''
exit 0
fi
./git-preview.sh
echo ''
END
)
git submodule update
echo ""
git submodule foreach "bash \"$create_preview\" 2>&1 | sed 's/^/ /'"
if [ $? -ne 0 ]; then
exit 1
fi
submodule_paths=$(git config --file .gitmodules --get-regexp path | awk '{ print $2 }')
for dir in $submodule_paths; do
git add $dir
done
git commit -m "merge submodule state" &> /dev/null
fi
echo "an up to date preview is ready!"