blob: 699d9e5d8a78533106e92efa14c36e4c6cdadcf2 (
plain) (
blame)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#
# Remote build&test script.
# Author: Aleksandar Prokopec
#
SCRIPTNAME="..:: RemoteTest ::.."
DESC="This script pushes the current git repo to a remote bare repo. \
It then checks out the source tree in a workspace repo and starts the\
build and all the tests. It can also initialize the remote bare repo\
and the workspace repo. It assumes that the current repo refspec has\
been set for the remote bare repository - .git/config of the current\
repo must have a remote called <server> and the corresponding master\
branch. Git should, naturally, be installed on both systems.\
"
USAGE=" Usage: remotetest [--init] <user> <server> <bare-repo-path> <workspace-repo-path>"
function usage()
{
echo $SCRIPTNAME
echo $DESC
echo
echo $USAGE
}
function error()
{
echo "Failed."
exit 1
}
function success()
{
echo "Success!"
exit 0
}
function instruct()
{
usage
error
}
if [ $# -lt 1 ]
then
instruct
fi
if [[ $1 = "--init" ]]
then
if [ $# -ne 5 ]
then
instruct
fi
USER=$2
LOCATION=$3
BAREREPO=$4
WORKREPO=$5
else
if [ $# -ne 4 ]
then
instruct
fi
USER=$1
LOCATION=$2
BAREREPO=$3
WORKREPO=$4
fi
if [[ $1 = "--init" ]]
then
# init bare repo
ssh $USER@$LOCATION "mkdir $BAREREPO"
ssh $USER@$LOCATION "cd $BAREREPO; git init --bare"
if [ $? -ne 0 ]
then
error "Could not initialize bare repo."
fi
# push to bare repo
git push --all
if [ $? -ne 0 ]
then
error "Could not push to bare repo."
fi
# init and checkout work repo
ssh $USER@$LOCATION "mkdir $WORKREPO"
ssh $USER@$LOCATION "cd $WORKREPO; git clone --local $BAREREPO ."
if [ $? -ne 0 ]
then
error "Could not init working repo."
fi
success
fi
# if it's not the init operation, proceed normally
# push to remote bare repo
git push $LOCATION $LOCATION/master
if [ $? -ne 0 ]
then
error "Could not push to bare repo."
fi
# remotely checkout the repo
ssh $USER@$LOCATION "cd $WORKREPO; git pull origin master"
if [ $? -ne 0 ]
then
error "Could remotely pull from bare repo to work repo."
fi
# run the build and tests
ssh $USER@$LOCATION "cd $WORKREPO; ant all.clean; ant test"
success
|