blob: 7cfee883b077b6d5ae865ad7d60745ede3e6d356 [file] [log] [blame]
Jeremy Mordkoff35d6f242016-10-06 16:17:05 -07001#!/bin/bash
garciadeblas3c25fab2019-11-18 17:24:43 +01002#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
Jeremy Mordkoff35d6f242016-10-06 16:17:05 -070015
16
17GIT() {
garciadeblase4606922017-01-04 14:28:04 +010018 CMD git "$@"
Jeremy Mordkoff35d6f242016-10-06 16:17:05 -070019}
20
21
22OSM_git_checkout() {
23
24 # Updates all the branches in the local repo (clones if it does not exist)
25 if [ -d $OSM_MDG ]; then
26 INFO "reusing existing workspace"
27 cd $OSM_MDG
garciadeblas1e9eff62017-03-15 10:23:03 +010028 GIT fetch --all --tags
Jeremy Mordkoff35d6f242016-10-06 16:17:05 -070029 #git checkout master #to make sure that we are in the right branch before pulling the code
30 #git pull
31 else
32 INFO "cloning MDG $OSM_MDG from $OSM_GIT_URL/$OSM_MDG"
33 GIT clone $OSM_GIT_URL/$OSM_MDG
34 cd $OSM_MDG
garciadeblase4606922017-01-04 14:28:04 +010035 for remote in `git branch -r |grep -v /HEAD`; do GIT branch --track ${remote#origin/} $remote; done
Jeremy Mordkoff35d6f242016-10-06 16:17:05 -070036 fi
37
38 if [ $# -gt 0 ]; then
39 if [ "$1" = "checkout" ]; then
40 INFO "Code to compile: '$2'"
41 GIT checkout $2
42 else
43 INFO "Code to compile: gerrit refspec '$1', commit-id: '$2'"
44 GIT fetch origin $1 || FATAL "git fetch origin '$1' didn't work"
45 GIT checkout -f $2 || FATAL "git checkout -f '$2' didn't work"
46 fi
47 else
48 INFO "Code to compile: master"
49 GIT checkout master
50 fi
51
52}
garciadeblase4606922017-01-04 14:28:04 +010053