-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathphp.remote
executable file
·73 lines (64 loc) · 1.98 KB
/
php.remote
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
71
72
73
#!/bin/bash
######################################################################
# Add remotes to build patched PHP ... because PHP ! #
######################################################################
BASE=$PWD
######################################################################
# STOP EDITING STOP EDITING STOP EDITING STOP EDITING STOP EDITING #
######################################################################
[ "x$BUILD" != "x" ] || BUILD=$BASE/php-build
######################################################################
# STOP EDITING STOP EDITING STOP EDITING STOP EDITING STOP EDITING #
######################################################################
NAME=$1
REMOTE=$2
######################################################################
# STOP EDITING STOP EDITING STOP EDITING STOP EDITING STOP EDITING #
######################################################################
USAGE="usage: php.remote name|list [remote]"
if [ -z $NAME ]; then
echo $USAGE
exit 1
fi
######################################################################
# STOP EDITING STOP EDITING STOP EDITING STOP EDITING STOP EDITING #
######################################################################
__msg()
{
echo -e "\033[0;32m${1}\033[0m"
}
__error()
{
echo -e "\033[0;35m${1}\033[0m"
}
remotes=$(git --git-dir=$BUILD/.src/.git remote show 2>/dev/null)
if [ $NAME == "list" ]; then
__msg "Available Remotes:"
for remote in $remotes
do
echo -e "\t$remote"
done
exit 0
elif [ -z $REMOTE ]; then
echo $USAGE
exit 1
fi
for remote in $remotes
do
if [[ $remote = $NAME ]]; then
__error "Cannot add existing remote source $remote"
exit 1
fi
done
git --git-dir=$BUILD/.src/.git remote add $NAME $REMOTE
if [ $? != 0 ]; then
__error "Failed to add remote $remote, git failed"
exit 1
fi
git --git-dir=$BUILD/.src/.git pull $NAME 2>/dev/null
if [ $? != 0 ]; then
__error "Failed to pull from remote $NAME"
exit 1
fi
__msg "Added remote $NAME -> $REMOTE"
exit 0